收藏
回答

wx.request 开启enableChunked: true后 千帆如何获取返回错误信息?

        const headers = {
        'Content-Type': 'application/json', //请求头这里不用改
        Accept: 'application/json'
    }
const requestTask = wx.request({
        url: url,
        timeout: 15000,
        responseType: 'text',
        method: 'POST',
        enableChunked: true,
        header: headers,
        data: data,
        success: (response: any) => {
            console.log('response 最后提交', response)
        },
        fail: (error: any) => {
            console.log('error', error)
        }
    })
    requestTask.onChunkReceived(function (res: any) {
        console.log('onChunkReceived', res.data)
 })

现在是,如果千帆接口正常返回数据,requestTask.onChunkReceived会执行,并且打印console.log('onChunkReceived', res.data) 。但是有时候千帆会提示错误,直接返回内容{"error_code":4,"error_msg":"request limit by resouce cluster reached","id":"as-m7vq23ptij"},requestTask.onChunkReceived就没有执行,success里面获取不到 {"error_code":4,"error_msg":"request limit by resouce cluster reached","id":"as-m7vq23ptij"}。请问要如何解决,有什么办法

回答关注问题邀请回答
收藏
登录 后发表内容