Skip to content

Commit

Permalink
add check for http 500, cleanup logs
Browse files Browse the repository at this point in the history
  • Loading branch information
Ak5cel committed Jan 15, 2024
1 parent 7a5e878 commit d5b7ed0
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions libs/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,8 @@ class RootApiService {
const delay = err.response.headers["retry-after"] | 1;
const delay_ms = delay * 1000;

console.log("waiting");
const delayRetry = new Promise((resolve) => {
setTimeout(() => {
console.log("retrying the request", originalConfig.url);
resolve();
}, delay_ms);
});
Expand All @@ -72,6 +70,13 @@ class RootApiService {
if (err.response.status === 403 && err.response.data) {
return Promise.reject(err.response.data);
}

if (err.response.status === 500) {
return Promise.reject({
status: 500,
msg: "Spotify Web API error: 500 - Internal Server Error. Please try again later.",
});
}
}

return Promise.reject(err);
Expand Down

0 comments on commit d5b7ed0

Please sign in to comment.