fix: fixed issue where 4xx errors were not being returned

This commit is contained in:
Anoop M D 2022-03-16 01:49:02 +05:30
parent ef9c6c493e
commit 6badca632b
2 changed files with 24 additions and 7 deletions

View File

@ -49,10 +49,27 @@ ipcMain.handle('grafnode-account-request', async (_, request) => {
// handler for sending http request
ipcMain.handle('send-http-request', async (_, request) => {
const result = await axios(request)
return {
status: result.status,
headers: result.headers,
data: result.data
};
try {
const result = await axios(request);
return {
status: result.status,
headers: result.headers,
data: result.data
};
} catch (error) {
if(error.response) {
return {
status: error.response.status,
headers: error.response.headers,
data: error.response.data
};
}
return {
status: -1,
headers: [],
data: null
};
}
})

View File

@ -28,7 +28,7 @@ const sendRequest = async (item, collectionUid, dispatch) => {
itemUid: item.uid
});
})
.catch((err) => console.log(err));
.catch((err) => console.error(err));
}
};