updated api to report failure to bugsnag and respond with fallback list

This commit is contained in:
Nouman Tahir 2023-03-14 18:38:37 +05:00
parent 4954f20c0c
commit 6a038c89c7

View File

@ -721,7 +721,23 @@ export const uploadImage = async (media, username, sign, uploadProgress = null)
// New image service
export const getNodes = () => serverList.get().then((resp) => resp.data.hived || SERVER_LIST);
export const getNodes = async () => {
try {
const response = await serverList.get('/');
console.log("nodes response", response.data);
if(!response.data?.hived){
throw new Error("Invalid data returned, fallback to local copy")
}
return response.data?.hived;
} catch (error) {
console.warn('failed to get nodes list', error);
bugsnagInstance.notify(error);
return SERVER_LIST
}
};
/**
* refreshes access token using refresh token