请求正常执行但是js语法报错Uncaught (in promise) TypeError: Cannot read properties of undefined (reading ‘code‘)
开发过程中发现前端请求正常执行,接口功能正常且正常返回数据,但是js仍然报语法错误Uncaught (in promise) TypeError: Cannot read properties of undefined (reading ‘code‘)原因:自定义拦截器后导出方法时忘记把promise对象return出去如下:正确处理方式应该将promise对象requestreturn出去,调用
·
开发过程中发现前端请求正常执行,接口功能正常且正常返回数据,但是js仍然报语法错误Uncaught (in promise) TypeError: Cannot read properties of undefined (reading ‘code‘)
原因:自定义拦截器后导出方法时忘记把promise对象return出去
如下:
正确处理方式应该将promise对象request
return出去,调用方法的位置才会是异步执行,就不会提示语法错误了
更多推荐
已为社区贡献4条内容
所有评论(0)