You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import { default as Axios } from 'axios';
import type { AxiosError, AxiosResponse, InternalAxiosRequestConfig } from 'axios';
import type { BaseResponse } from '~/@types';
export default defineNuxtPlugin((nuxtApp) => {
const axios = Axios.create({ baseURL: nuxtApp.$config.public.BASE_URL });
const toastService = useToastService();
const token = useCookie(`${nuxtApp.$config.public.APP_NAME}_token`);
axios.interceptors.request.use((config: InternalAxiosRequestConfig) => {
if (token) {
config.headers.Authorization = `Bearer ${token.value}`;
}
return config;
});
axios.interceptors.response.use(
<T>(response: AxiosResponse) => {
let res: Promise<never> | AxiosResponse<BaseResponse<T>>;
switch (response.data.status_code) {
case 401:
token.value = null;
res = Promise.reject(response);
location.reload();
break;
case 403:
res = Promise.reject(response);
break;
case 422:
res = Promise.reject(response);
break;
case 500:
res = response;
break;
default:
res = response;
break;
}
return res;
},
(error: AxiosError) => {
toastService.add({ severity: 'error', summary: 'ERROR', detail: error.message, life: 5000 });
return Promise.reject(error.message);
}
);
return {
provide: {
axios
}
};
});
Describe the bug
Got this warning after upgrading nuxt to 3.11.0:
Failed to parse static properties from plugin plugins/axios.ts. Transform failed with 2 errors: 2:59:23 AM
<stdin>:19:34: ERROR: The character ">" is not valid inside a JSX element
<stdin>:20:10: ERROR: Expected "}" but found "res"
<stdin>:19:34: ERROR: The character ">" is not valid inside a JSX element
<stdin>:20:10: ERROR: Expected "}" but found "res"
at failureErrorWithLog (node_modules\esbuild\lib\main.js:1651:15)
at node_modules\esbuild\lib\main.js:849:29
at responseCallbacks.<computed> (node_modules\esbuild\lib\main.js:704:9)
at handleIncomingPacket (node_modules\esbuild\lib\main.js:764:9)
at Socket.readFromStdout (node_modules\esbuild\lib\main.js:680:7)
at Socket.emit (node:events:513:28)
at addChunk (node:internal/streams/readable:324:12)
at readableAddChunk (node:internal/streams/readable:297:9)
at Readable.push (node:internal/streams/readable:234:10)
at Pipe.onStreamRead (node:internal/stream_base_commons:190:23)
Warning is gone when i delete generic types. Plugin is still working btw.
Additional context
No response
Logs
No response
The text was updated successfully, but these errors were encountered:
Environment
Reproduction
plugins/axios.ts
Describe the bug
Got this warning after upgrading nuxt to 3.11.0:
Warning is gone when i delete generic types. Plugin is still working btw.
Additional context
No response
Logs
No response
The text was updated successfully, but these errors were encountered: