mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
fix: returns a stub score (0) in case score api throws an error
This commit is contained in:
parent
ba28e54f7c
commit
6bb11ce99b
1 changed files with 17 additions and 7 deletions
|
|
@ -1,5 +1,6 @@
|
|||
import axios from 'axios'
|
||||
import { env } from '../env'
|
||||
import { logError } from '../utils/logger'
|
||||
|
||||
export interface Feature {
|
||||
library_item_id?: string
|
||||
|
|
@ -63,14 +64,23 @@ class ScoreClientImpl implements ScoreClient {
|
|||
}
|
||||
|
||||
async getScores(data: ScoreApiRequestBody): Promise<ScoreApiResponse> {
|
||||
const response = await axios.post<ScoreApiResponse>(this.apiUrl, data, {
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
timeout: 5000,
|
||||
})
|
||||
try {
|
||||
const response = await axios.post<ScoreApiResponse>(this.apiUrl, data, {
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
timeout: 5000,
|
||||
})
|
||||
|
||||
return response.data
|
||||
return response.data
|
||||
} catch (error) {
|
||||
logError(error)
|
||||
|
||||
// Returns a stub score (0) in case of an error
|
||||
return {
|
||||
[Object.keys(data.items)[0]]: { score: 0 },
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue