如果我问了一个愚蠢的问题,请提前道歉。我进行了搜索,但没有找到我要找的答案。
我需要将 Promise 返回的 index 值作为参数传递给我的 Observable:
deleteFavorite(token: string, recipe: Recipe) {
const userId = this.authService.getActiveUser().uid;
let index: number;
this.indexOfFavoriteToBeRemoved(recipe)
.then(
index => {
console.log(index)
}
);
return this.http.delete(this.databaseAddress + userId + '/' + index + '.json?auth=' + token)
.map(
(response: Response) => {
return response.json();
}
);
}