Skip to content

Commit

Permalink
Fix Review
Browse files Browse the repository at this point in the history
  • Loading branch information
ggazzo committed Jun 16, 2022
1 parent fbf7fbe commit 4cdfa42
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
13 changes: 7 additions & 6 deletions apps/meteor/app/utils/client/lib/RestApiClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,14 @@ export const APIClient = new RestApiClient({

APIClient.use(async function (request, next) {
try {
const res = await next(...request);
if (!res.ok) {
throw await res.json();
return await next(...request);
} catch (error) {
if (!(error instanceof Response) || error.status !== 400) {
throw error;
}
return res;
} catch (e) {
return new Promise((resolve, reject) => {

return new Promise(async (resolve, reject) => {
const e = await error.json();
process2faReturn({
error: e,
result: null,
Expand Down
5 changes: 5 additions & 0 deletions packages/api-client/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,11 @@ export class RestClient implements RestClientInterface {
...options,
headers: { ...this.getCredentialsAsHeaders(), ...this.headers, ...headers },
method,
}).then(function (response) {
if (!response.ok) {
return Promise.reject(response);
}
return response;
});
}

Expand Down

0 comments on commit 4cdfa42

Please sign in to comment.