mirror of
https://github.com/20kaushik02/spotify-manager-web.git
synced 2025-12-06 08:04:06 +00:00
fix
This commit is contained in:
parent
d7addccbc7
commit
f54d8ccee6
@ -30,29 +30,29 @@ const APIWrapper = async <T extends apiRespBaseType>({
|
||||
data,
|
||||
config,
|
||||
}: APIWrapperProps<T>) => {
|
||||
let apiResp;
|
||||
for (let i = 1; i <= maxRetries + 1; i++) {
|
||||
const apiResp = await apiFn(data, config);
|
||||
apiResp = await apiFn(data, config);
|
||||
|
||||
if (apiResp === undefined) {
|
||||
showErrorToastNotification("Please try again after sometime");
|
||||
} else if (apiResp.status >= 200 && apiResp.status < 300) {
|
||||
return apiResp;
|
||||
break;
|
||||
} else if (apiResp.status === 401) {
|
||||
showWarnToastNotification("Session expired, refreshing...");
|
||||
if (!(await refreshAuth())) {
|
||||
showErrorToastNotification("Session invalid.");
|
||||
return;
|
||||
break;
|
||||
}
|
||||
} else if (apiResp.status >= 400 && apiResp.status < 500) {
|
||||
showErrorToastNotification(apiResp.data.message);
|
||||
return; // no retry on 4XX
|
||||
break; // no retry on 4XX
|
||||
} else {
|
||||
showErrorToastNotification(apiResp.data.message);
|
||||
}
|
||||
await sleep(i * i * 1000);
|
||||
}
|
||||
showErrorToastNotification("Please try again after sometime");
|
||||
return;
|
||||
return apiResp;
|
||||
};
|
||||
|
||||
export default APIWrapper;
|
||||
|
||||
@ -164,7 +164,6 @@ const Graph = () => {
|
||||
|
||||
const onConnect: OnConnect = useCallback(
|
||||
async (connection) => {
|
||||
setLinkEdges((eds) => addEdge(connection, eds));
|
||||
console.debug(
|
||||
`new connection: ${connection.source} -> ${connection.target}`
|
||||
);
|
||||
@ -178,8 +177,10 @@ const Graph = () => {
|
||||
},
|
||||
refreshAuth,
|
||||
});
|
||||
if (resp?.status === 201)
|
||||
if (resp?.status === 201) {
|
||||
showSuccessToastNotification(resp?.data.message);
|
||||
setLinkEdges((eds) => addEdge(connection, eds));
|
||||
}
|
||||
},
|
||||
[setLinkEdges, refreshAuth]
|
||||
);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user