Skip to content

Commit

Permalink
updated logging
Browse files Browse the repository at this point in the history
  • Loading branch information
H34D committed Nov 22, 2022
1 parent 4358495 commit 0c417db
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/common/helpers/rest-calls/index.ts
Expand Up @@ -105,10 +105,11 @@ export const useMasaQuery = (

const { token } = useAccessToken();

const url = `${URL(apiURL)}${fullPath}`;
const query = useQuery(
name,
() =>
fetch(`${URL(apiURL)}${fullPath}`, {
fetch(url, {
headers: {
...headers,
Authorization: token ? `Bearer ${token}` : undefined,
Expand All @@ -124,11 +125,14 @@ export const useMasaQuery = (
console.log('NOT OK');
}
if (res.status > 399) {
throw new Error('ERR');
throw new Error(
`Received Error Code during fetch: ${res.status} at ${url}`
);
}
return res.json();
})
.catch((err) => {
console.error('Query failed!:', err.message, url);
throw new Error(err);
}),
{
Expand Down

0 comments on commit 0c417db

Please sign in to comment.