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