Skip to content

Instantly share code, notes, and snippets.

@Hawksbillcat
Created March 12, 2019 07:47
Show Gist options
  • Save Hawksbillcat/e1ab8520fd396713c300cdd1fe7c1755 to your computer and use it in GitHub Desktop.
Save Hawksbillcat/e1ab8520fd396713c300cdd1fe7c1755 to your computer and use it in GitHub Desktop.
async compair_phone_book(){
let test_set=[];//先塞PROMISE給ALL用
let setting=[];
let a;
return new Promise((resolve,reject)=>{
this.get_phone_book().then(res=>{
const b =JSON.parse(JSON.stringify(res));
b.map(i=>{
test_set.push(new Promise((resolve,reject)=>{
this.http.get("url/contact="+i).subscribe(res=>{
resolve(res)
})
}))
})
resolve(test_set)//爬到的是json array
})
})
this.compair_phone_book().then(res=>{
console.log(res)
//[T,T,T,T] 無法放到promise.all()
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment