nuxt或者vue,axios中如何发送多个请求

在使用vue或者nuxt中,我们需要使用axios去发送多个http请求,参考了axios的官方说明你也许会想到使用axios.all发送请求,但是这样可能会出现一些异常错误:

(node:9360) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): TypeError: __WEBPACK_IMPORTED_MODULE_2__plugins_axios__.a.all is not a function

所以正确的使用姿势是采用Promise.all 来发送多个请求. 具体实现请参考如下实现:

Heap Stack Blog(pingbook.top)Nuxt How to send multiple requests in asyncData

posted @ 2019-09-24 20:12  高级测试开发网  阅读(1144)  评论(0编辑  收藏  举报
了解开发资源最新动态:https://seniortesting.club