您好,欢迎来到化拓教育网。
搜索
您的当前位置:首页Promise.all() 但凡遇到reject就停止其他请求的

Promise.all() 但凡遇到reject就停止其他请求的

来源:化拓教育网

解决核心思路,增加map

Promise.all([p1, p2].map(p => p.catch(e => e)))
Promise.all([p1, p2].map(p => p.catch(e => e)))
          .then(results => {
              let companyResult = results[0]
              let securityQuestionsResult = results[1]
              if(!(companyResult instanceof Error)){
                 = 
                this.model.postalCode = companyResult.data.postCode
              }
              if(!(securityQuestionsResult instanceof Error)){
                this.model.securityQuestionArr = securityQuestionsResult.data
              }
          })
          .catch(e => {
            this.$parent.loading = false
          })
          .finally(() => {
            this.$parent.loading = false
          })

Copyright © 2019- huatuo9.cn 版权所有 赣ICP备2023008801号-1

违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务