Skip to content

Commit

Permalink
backendFetchSilent to avoid wordbazzar errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Yury Shapkarin committed Mar 16, 2021
1 parent aca3283 commit a7915e2
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/utils/backend.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,19 @@ const backendFetch = (path, ...args) => wrapTry(
fetch(`${process.env.VUE_APP_BACKEND_URL}/${path}`, ...args).catch((err) => console.error(err), store),
);

const backendFetchSilent = async (path, ...args) => {
const promise = fetch(`${process.env.VUE_APP_BACKEND_URL}/${path}`, ...args).catch((err) => console.error(err), store);
// eslint-disable-next-line no-useless-catch
try {
return promise.then((res) => {
if (!res.ok) console.log(`endpoint ${process.env.VUE_APP_BACKEND_URL}/${path}} responce with code: ${res.status}`);
return res.json();
});
} catch (err) {
console.log(`endpoint ${process.env.VUE_APP_BACKEND_URL}/${path}} responce with error: ${err}`);
}
};

const backendFetchNoTimeout = (path, ...args) => fetch(`${process.env.VUE_APP_BACKEND_URL}/${path}`, ...args)
.catch((err) => console.error(err));

Expand Down Expand Up @@ -116,7 +129,7 @@ export default class Backend {
if (ordering) queryParams.set('ordering', ordering);
if (direction) queryParams.set('direction', direction);
if (search) queryParams.set('search', search);
return backendFetch(`tokenCache/wordRegistry?${queryParams.toString()}`);
return backendFetchSilent(`tokenCache/wordRegistry?${queryParams.toString()}`);
}

static getWordSaleVotesDetails = async (address) => backendFetch(`tokenCache/wordSaleVotesDetails/${address}`);
Expand Down

0 comments on commit a7915e2

Please sign in to comment.