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