第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

Promise Chaining 未按預(yù)期工作

Promise Chaining 未按預(yù)期工作

qq_笑_17 2021-08-20 19:20:58
我正在嘗試對(duì)我從我的角度應(yīng)用程序進(jìn)行的 $http.get 調(diào)用使用承諾鏈接$http.get(url, config)    .then(newViewRequest)    .then(function (response) { // success async        $scope.viewRequest1.data = response.data;    }在我的 newViewRequest 中,我對(duì)其他端點(diǎn)進(jìn)行了新的調(diào)用,如果 newViewRequest 中的調(diào)用成功,我只需要發(fā)回響應(yīng)。以下是我正在嘗試的var newViewRequest = function (response) {    var url1 = $rootScope.BaseURL;    var config = {        headers: {            'Authorization': `Basic ${$scope.key}`,            'Prefer': 'odata.maxpagesize=2000'        }    };     var newresponse = $http.get(url1, config);    if (newresponse.status = 200)        return newresponse;    else return response;};但它總是發(fā)送請(qǐng)求響應(yīng)而不驗(yàn)證狀態(tài)或任何東西。我該如何解決這個(gè)問題。
查看完整描述

1 回答

?
明月笑刀無情

TA貢獻(xiàn)1828條經(jīng)驗(yàn) 獲得超4個(gè)贊

將$http.get在newViewRequest返回的承諾。您需要等待它解決才能獲得狀態(tài)。并且您必須返回 PromisenewViewRequest以進(jìn)行正確的鏈接。


return $http.get(url1, config)

.then(newresponse => {

  if (newresponse.status = 200)

    return newresponse;

  else return response;

})

.catch(err => {

  return response;

})


查看完整回答
反對(duì) 回復(fù) 2021-08-20
  • 1 回答
  • 0 關(guān)注
  • 159 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)