xgqfrms™, xgqfrms® : xgqfrms's offical website of cnblogs! xgqfrms™, xgqfrms® : xgqfrms's offical website of GitHub!

Axios post bugs All In One

Axios post bugs All In One

solution

屏蔽细节

import axios from '@/utils/http.js';


// 保存创意
const axiosUtils = (url = '', params = {}, type = 'get') => {
    if(!url) {
        throw new Error('❌ API URL 不可为空!');
        // return;
    }
    // switch...case
    if(type === 'get') {
        // multipart/form-data ✅
        return axios.post(url, {params});
    }
    if(type === 'post') {
        // application/x-www-form-urlencoded ✅✅
        return axios.post(url, params);
    }
    if(type === 'put') {
        // multipart/form-data ✅✅
        return axios.post(url, params);
    }
};

refs

https://github.com/xgqfrms/FEIQA/issues/107



©xgqfrms 2012-2020

www.cnblogs.com 发布文章使用:只允许注册用户才可以访问!

原创文章,版权所有©️xgqfrms, 禁止转载 🈲️,侵权必究⚠️!


posted @ 2021-05-20 18:44  xgqfrms  阅读(52)  评论(6编辑  收藏  举报