Skip to content

Commit

Permalink
rethrow
Browse files Browse the repository at this point in the history
  • Loading branch information
leonardocustodio committed Aug 12, 2023
1 parent 6264fa5 commit df9da78
Showing 1 changed file with 21 additions and 17 deletions.
38 changes: 21 additions & 17 deletions resources/js/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,25 +63,29 @@ export class ApiService {
url: `${appStore.config.url}graphql${schema}`,
data,
credentials: useAppStore().isMultiTenant ? 'include' : 'omit',
}).then((res: any) => {
if (res.errors) {
const message = res.errors[0].message;
if (message === 'validation') {
const error = res.errors[0].extensions?.validation;
const errors = Object.keys(error).map((key) => {
return {
field: key,
message: error[key][0],
};
});
reject(errors);
})
.then((res: any) => {
if (res.errors) {
const message = res.errors[0].message;
if (message === 'validation') {
const error = res.errors[0].extensions?.validation;
const errors = Object.keys(error).map((key) => {
return {
field: key,
message: error[key][0],
};
});
reject(errors);
} else {
reject({ field: 'Error', message });
}
} else {
reject({ field: 'Error', message });
resolve(res);
}
} else {
resolve(res);
}
});
})
.catch((err) => {
throw err;
});
}).catch((err) => {
throw err;
});
Expand Down

0 comments on commit df9da78

Please sign in to comment.