diff --git a/packages/core/email/admin/src/pages/Settings/utils/api.js b/packages/core/email/admin/src/pages/Settings/utils/api.js index b2353b24d8..9c8beb4d4b 100644 --- a/packages/core/email/admin/src/pages/Settings/utils/api.js +++ b/packages/core/email/admin/src/pages/Settings/utils/api.js @@ -1,13 +1,16 @@ -import axiosInstance from '../../../utils/axiosInstance'; +import { getFetchClient } from '@strapi/helper-plugin'; const fetchEmailSettings = async () => { - const { data } = await axiosInstance.get('/email/settings'); + const { get } = getFetchClient(); + const { data } = await get('/email/settings'); return data.config; }; const postEmailTest = async (body) => { - await axiosInstance.post('/email/test', body); + const { post } = getFetchClient(); + + await post('/email/test', body); }; export { fetchEmailSettings, postEmailTest }; diff --git a/packages/core/email/admin/src/utils/axiosInstance.js b/packages/core/email/admin/src/utils/axiosInstance.js deleted file mode 100644 index 3210d5ebe9..0000000000 --- a/packages/core/email/admin/src/utils/axiosInstance.js +++ /dev/null @@ -1,38 +0,0 @@ -import axios from 'axios'; -import { auth, wrapAxiosInstance } from '@strapi/helper-plugin'; - -const instance = axios.create({ - baseURL: process.env.STRAPI_ADMIN_BACKEND_URL, -}); - -instance.interceptors.request.use( - async (config) => { - config.headers = { - Authorization: `Bearer ${auth.getToken()}`, - Accept: 'application/json', - 'Content-Type': 'application/json', - }; - - return config; - }, - (error) => { - Promise.reject(error); - } -); - -instance.interceptors.response.use( - (response) => response, - (error) => { - // whatever you want to do with the error - if (error.response?.status === 401) { - auth.clearAppStorage(); - window.location.reload(); - } - - throw error; - } -); - -const wrapper = wrapAxiosInstance(instance); - -export default wrapper;