md/src/api/fetch.js
JimQing b50ae32834
refactor: use uni-app framework (#55)
* update framework to uni-app

* fix: bug fix

* fix: bug fix

* 修改输出路径

* feat: publicPath

* feat: manifest update

* fix: cssEditor theme

* fix: style

* style: format code with prettier

* fix: table style & copy style on the night mode

* fix: upload image

* fix: style

Co-authored-by: yanglbme <szuyanglb@outlook.com>
2021-02-28 14:50:52 +08:00

31 lines
621 B
JavaScript

import axios from "axios";
// 创建axios实例
const service = axios.create({
baseURL: "",
timeout: 10 * 1000, // 请求超时时间
});
service.interceptors.request.use(
(config) => {
if (/^(post)|(put)|(delete)$/i.test(config.method)) {
if (config.data && config.data.upload) {
config.headers["Content-Type"] = "multipart/form-data";
}
}
return config;
},
(error) => {
Promise.reject(error);
}
);
service.interceptors.response.use(
(res) => {
return res.data ? res.data : Promise.reject(res);
},
(error) => Promise.reject(error)
);
export default service;