我有從數據鏈接數組上傳文件的功能我想做的是如果數據鏈接數組包含 3 個文件const testLinks = 3;并且async uploadImageData被解雇了三次我想在被解雇了三次console.log之后。uploadImageData我正在考慮進行計數,但我所有的測試都會在每次被觸發時重新開始計數uploadImageData。.tsasync uploadImageData(formData: FormData) { const testLinks = 3; const uploadlink = answerAtachmentUrl; const headers = headerLink; const loading = await this.loadingController.create({ message: 'Uploading Photos and Files...', }); await loading.present(); this.httpClient.post<any>( uploadlink + this.userToken, formData, { 'headers':headers } ).pipe( finalize(() => { loading.dismiss();}) ) .subscribe(res => { if (res['success']) { setTimeout(() => { this.DeleteAllFiles(); }, 5000); this.presentToastPhoto('Photo sync success.'); } else { this.presentToastPhoto('Photo upload failed.'); let respFail = JSON.stringify(res); console.log("respFail", respFail); } }); // console.log fires once after count and const testLinks both equal 3}
有沒有辦法計算異步函數被調用的次數?
慕容森
2023-08-24 18:01:27