mirror of
https://github.com/strapi/strapi.git
synced 2025-11-26 23:22:01 +00:00
replace axiosInstance with the get and post methods in the getFetchClient inside the fetchEmailSettings and postEmailTest utils
This commit is contained in:
parent
62f1c3d04a
commit
4c8c7cf38f
@ -1,13 +1,16 @@
|
|||||||
import axiosInstance from '../../../utils/axiosInstance';
|
import { getFetchClient } from '@strapi/helper-plugin';
|
||||||
|
|
||||||
const fetchEmailSettings = async () => {
|
const fetchEmailSettings = async () => {
|
||||||
const { data } = await axiosInstance.get('/email/settings');
|
const { get } = getFetchClient();
|
||||||
|
const { data } = await get('/email/settings');
|
||||||
|
|
||||||
return data.config;
|
return data.config;
|
||||||
};
|
};
|
||||||
|
|
||||||
const postEmailTest = async (body) => {
|
const postEmailTest = async (body) => {
|
||||||
await axiosInstance.post('/email/test', body);
|
const { post } = getFetchClient();
|
||||||
|
|
||||||
|
await post('/email/test', body);
|
||||||
};
|
};
|
||||||
|
|
||||||
export { fetchEmailSettings, postEmailTest };
|
export { fetchEmailSettings, postEmailTest };
|
||||||
|
|||||||
@ -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;
|
|
||||||
Loading…
x
Reference in New Issue
Block a user