OS
let url = "https://graph.facebook.com/v6.0/me/adaccounts";
return this._http.get(url+token);
вот такое GetDataOfAds возвращает . Запросы все уходят
Size: a a a
OS
let url = "https://graph.facebook.com/v6.0/me/adaccounts";
return this._http.get(url+token);
BK
for(let i = 0; i < Object.keys(dbData).length; i++){
this.facebookService.getDataOfAds(dbData[i].token)
.toPromise()
.then(response => {
})
.catch((err:any) => {
console.log(err);
});
}
AB
OS
console.log(Object.keys(dbData)
.map(key => this
.getData(dbData[key])
.pipe(
catchError(error => of('something goes wrong'))
))
OS
forkJoin(Object.keys(dbData)
.map((key) => {
this.facebookService.getDataOfAds(dbData[key].token)
.pipe(catchError(error => of('something goes wrong')))
})).subscribe(
returnesponse => {
console.log('success',returnesponse);
},
error => {
console.log('error',error);
});
BK
П
OS
return this._http.get(url+token);http - это angular http client?
OS
BK
getAllDataFromDb(){
return this.db.getAllDataFromDb().toPromise().then(dbData => {
forkJoin(Object.keys(dbData)
.map((key) => {
this.facebookService.getDataOfAds(dbData[key].token)
.pipe(catchError(error => of('something goes wrong')))
.toPromise()
.then(response => {
console.log("304",response);
this.ls.addItem(response,dbData[key]);
})
.catch((err:any) => {
console.log(err);
});
}))
.subscribe(() =>
console.log("success")
);
if(Object.keys(dbData).length == 0){
this.data = [];
localStorage.removeItem("data");
}
})
//если ошибка
.catch((err:any) => {
console.log(err);
});
}
OS
OS
return forkJoin(Object.keys(dbData)
.map((key) => {
this.facebookService.getDataOfAds(dbData[key].token)
.pipe(catchError(error => of('something goes wrong')))
}))
🇻
BK
return forkJoin(Object.keys(dbData)
.map((key) => {
this.facebookService.getDataOfAds(dbData[key].token)
.pipe(catchError(error => of('something goes wrong')))
}))
🇻
OS
OS
return forkJoin().pipe(map(data => handle(data)))Где handle - это логика
OS
OS
getAllDataFromDb(){
return this.db.getAllDataFromDb().toPromise().then(dbData => {
forkJoin(Object.keys(dbData)
.map((key) => {
this.facebookService.getDataOfAds(dbData[key].token)
.pipe(catchError(error => of('something goes wrong')))
.toPromise()
.then(response => {
console.log("304",response);
this.ls.addItem(response,dbData[key]);
})
.catch((err:any) => {
console.log(err);
});
}))
.subscribe(() =>
console.log("success")
);
if(Object.keys(dbData).length == 0){
this.data = [];
localStorage.removeItem("data");
}
})
//если ошибка
.catch((err:any) => {
console.log(err);
});
}