Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'map')
时间: 2023-09-20 20:14:45 浏览: 267
这个问题的报错信息是"Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'map')",根据提供的引用内容,我们可以得到一些关于这个问题的解答。
引用和引用提供的代码片段显示,这个问题出现在commit()方法之前的resolve()方法被调用的时候。根据这两个引用,可以看出在调用resolve()方法之前应该先调用commit()方法才能避免这个错误。
另外,引用提供的信息也提到了类似的错误,解决方法是确保在自定义拦截器中返回promise对象。这个问题的解决方法类似,需要确保在正确的时候调用resolve()方法。
综上所述,为了解决"Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'map')"错误,你可以将commit()方法的调用放在resolve()方法之前。这样可以确保在调用resolve()方法之前已经处理了必要的操作,避免了undefined的错误。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *2* [Uncaught (in promise)和Uncaught (in promise) TypeError: Cannot read properties of undefined (readin](https://blog.csdn.net/weixin_40476233/article/details/126107676)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 50%"]
- *3* [请求正常执行但是js语法报错Uncaught (in promise) TypeError: Cannot read properties of undefined ...](https://blog.csdn.net/qq_41790461/article/details/124386209)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文