forked from verdnatura/salix-front
feat: refs #7828 create axios instance which no manage errors
This commit is contained in:
parent
58be11df04
commit
48a5c15b9d
|
@ -5,8 +5,10 @@ import useNotify from 'src/composables/useNotify.js';
|
|||
|
||||
const session = useSession();
|
||||
const { notify } = useNotify();
|
||||
const baseUrl = '/api/';
|
||||
|
||||
axios.defaults.baseURL = '/api/';
|
||||
axios.defaults.baseURL = baseUrl;
|
||||
const axiosNoError = axios.create({ baseURL: baseUrl });
|
||||
|
||||
const onRequest = (config) => {
|
||||
const token = session.getToken();
|
||||
|
@ -79,5 +81,7 @@ const onResponseError = (error) => {
|
|||
|
||||
axios.interceptors.request.use(onRequest, onRequestError);
|
||||
axios.interceptors.response.use(onResponse, onResponseError);
|
||||
axiosNoError.interceptors.request.use(onRequest);
|
||||
axiosNoError.interceptors.response.use(onResponse);
|
||||
|
||||
export { onRequest, onResponseError };
|
||||
export { onRequest, onResponseError, axiosNoError };
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
import { useI18n } from 'vue-i18n';
|
||||
import { useRoute } from 'vue-router';
|
||||
import { onMounted, ref, computed, onBeforeMount, nextTick, reactive } from 'vue';
|
||||
import { axiosNoError } from 'src/boot/axios';
|
||||
|
||||
import FetchData from 'components/FetchData.vue';
|
||||
import WorkerTimeHourChip from 'pages/Worker/Card/WorkerTimeHourChip.vue';
|
||||
|
@ -266,10 +267,11 @@ const fetchWeekData = async () => {
|
|||
};
|
||||
try {
|
||||
const mail = (
|
||||
await axios.get(`Workers/${route.params.id}/mail`, {
|
||||
await axiosNoError.get(`Workers/${route.params.id}/mail`, {
|
||||
params: { filter: { where } },
|
||||
})
|
||||
).data[0];
|
||||
|
||||
if (!mail) state.value = null;
|
||||
else {
|
||||
state.value = mail.state;
|
||||
|
@ -277,7 +279,7 @@ const fetchWeekData = async () => {
|
|||
}
|
||||
|
||||
canResend.value = !!(
|
||||
await axios.get('WorkerTimeControlMails/count', { params: { where } })
|
||||
await axiosNoError.get('WorkerTimeControlMails/count', { params: { where } })
|
||||
).data.count;
|
||||
} catch (err) {
|
||||
console.error('Error fetching week data');
|
||||
|
|
Loading…
Reference in New Issue