fix: digest score api timeout = 5 seconds

This commit is contained in:
Hongbo Wu
2024-06-28 16:38:00 +08:00
parent a7ba02e063
commit 0dada2d708

View File

@ -1,3 +1,4 @@
import axios from 'axios'
import { env } from '../env'
export interface Feature {
@ -62,20 +63,14 @@ class ScoreClientImpl implements ScoreClient {
}
async getScores(data: ScoreApiRequestBody): Promise<ScoreApiResponse> {
const response = await fetch(this.apiUrl, {
method: 'POST',
const response = await axios.post<ScoreApiResponse>(this.apiUrl, data, {
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(data),
timeout: 5000,
})
if (!response.ok) {
throw new Error(`Failed to score candidates: ${response.statusText}`)
}
const scores = (await response.json()) as ScoreApiResponse
return scores
return response.data
}
}