mirror of
https://github.com/muerwre/orchidmap-front.git
synced 2025-05-06 00:16:40 +07:00
added post map interceptor
This commit is contained in:
parent
fda24c78b0
commit
9c436d348c
5 changed files with 33 additions and 29 deletions
14
src/utils/api/interceptors.ts
Normal file
14
src/utils/api/interceptors.ts
Normal file
|
@ -0,0 +1,14 @@
|
|||
import { AxiosError } from 'axios';
|
||||
import { PostMapResponse } from '~/utils/api/types';
|
||||
|
||||
export const postMapInterceptor = (res: AxiosError<PostMapResponse>) => {
|
||||
if (res.response?.data.code) {
|
||||
return res.response;
|
||||
}
|
||||
|
||||
if (res.response?.data.error) {
|
||||
throw new Error(res.response?.data.error);
|
||||
}
|
||||
|
||||
throw res;
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue