123456789101112131415161718192021222324252627282930 |
- const axios_instance = axios.create({
- baseURL: baseUrl + "mobile",
- timeout: 30000,
- headers: {'X-Requested-With':'XMLHttpRequest'},
- withCredentials: true,
- });
- axios_instance.interceptors.response.use(function (response) {
- const data = response.data;
- if (data.code === 1) {
- if (typeof error === 'function') {
- error(data.data);
- } else {
- Toast(data.msg);
- }
- } else if (data.code === 401) {
- location.href = '/mobile/login/login';
- }
- return response.data;
- });
- async function postJson(url,data) {
- return new Promise((resolve, reject) => {
- axios_instance.post(url, JSON.stringify(data), {
- headers: { 'Content-Type': 'application/json;charset=UTF-8' }
- }).then((result) => {
- return resolve(result.data);
- });
- });
- }
|