Apologies in advance if asking a dumb question. I did a search and could not find the answer I was looking for.
I need the value for index which is returned in the Promise to be passed to my Observable as an argument:
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();
}
);
}