1***@qq.com
1***@qq.com
  • 发布:2021-02-22 14:53
  • 更新:2021-02-22 15:02
  • 阅读:521

#插件讨论# 【 axios-miniprogram - zjx9495 】axios-miniprogram 出现迭代异常日志?

分类:uni-app

在小程序里面使用 请求出现错误

     MiniProgramError  
Invalid attempt to destructure non-iterable instance.  
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.  
TypeError: Invalid attempt to destructure non-iterable instance.  
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.

我是这样配置的

   import axios from '@/common/axios-miniprogram/axios/es/index.js'  

const service = axios.create({  
    baseURL: baseUrl, // url = base url + request url  
      // withCredentials: true, // send cookies when cross-domain requests  
    timeout: 600000  
})  

// 添加请求拦截器  
service.interceptors.request.use((config) => {  
  // 在发送请求之前做些什么  
  console.log('request');  
  return config;  
}, (error) => {  
  //处理请求错误  
  return Promise.reject(error);  
});  

// 添加响应拦截器  
service.interceptors.response.use((response) =>  {  
  // 请求成功后做些什么  
  const data = response.data  
  console.log('response');  
  if(response.status !== 200){  
      return Promise.reject(error);  
  }else if( data.code != 200 ){  
      uni.showToast({  
        title:data.msg,  
        icon:'none'  
      })  
       return Promise.reject(data.msg);  
  }  
  return data;  
}, (error) =>  {  
  // 处理响应错误  
  return Promise.reject(error);  
});  

export default service

这样有问题吗?

拦截器注释掉之后还是有这样的问题.也不知道是什么原因

2021-02-22 14:53 负责人:无 分享
已邀请:
flufff

flufff

这个错误下班后帮你解决

flufff

flufff

可能是插件语法错误

flufff

flufff

把详细的错误信息给我 ,包括堆栈信息

  • 1***@qq.com (作者)

    不好意思,昨天没有看网站了,我把异常和堆栈信息发出来

    2021-02-23 10:13

  • 1***@qq.com (作者)

    VM17:1 TypeError: Invalid attempt to destructure non-iterable instance.  
    In order to be iterable, non-array objects must have a [Symbol.iterator]() method.
    at _nonIterableRest (index.js:195)
    at _slicedToArray (index.js:193)
    at _callee$ (index.vue:195)
    at tryCatch (runtime.js?96cf:62)
    at Generator.invoke [as _invoke] (runtime.js?96cf:288)
    at Generator.prototype.<computed> [as next] (runtime.js?96cf:114)
    at asyncGeneratorStep (index.js:173)
    at _next (index.js:186)

    2021-02-23 10:14

要回复问题请先登录注册