orchidmap-front/src/utils/api/interceptors.ts
2021-04-20 16:39:51 +07:00

14 lines
329 B
TypeScript

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;
};