import axios from "axios"; // create an axios instanceconst service = axios.create({ baseURL: "", timeout: 5000}); // request interceptorservice.interceptors.request.use( config => { config.headers["timestamp"] = Math.ceil(new Date().getTime() / 1000); config.headers["Content-Type"] = "application/json; charset=utf-8"; return config; }, error => { return Promise.reject(error); }); // response interceptorservice.interceptors.response.use( response => { return response.data; }, error => { return Promise.reject(error); }); export default service;Copy the code