支付宝小程序axios调试报错:adapter is not a function

1,168 阅读1分钟

错误如下:

image.png

解决方案:

axios.defaults.adapter 进行封装:

axios.defaults.adapter = function (config) {
    return new Promise((resolve, reject) => {
        my.request({
            url: config.url,
            headers: config.headers,
            method: 'POST',
            data: config.data,
            dataType: 'text',
            success: function (res) {
                resolve(res)
            },
            fail: function (res) {
                reject(res)
            }
        });
    })
}

参考链接:blog.csdn.net/lys_xm/arti…