I have a HTTP get request that use a book name in url to find a price for the book. I added a loop to get all the prices of the books added to to array. But it seems like the next iterations don't go through. Books[0] works fine and price are added from the API.
When I try to log the iterations, it also stops after index 0.
books: { name: String, price: String} [] = [
{ "name": "dash", "price": "N/A" }
{ "name": "tash", "price": "N/A" }
{ "name": "mash", "price": "N/A" }
];
getti() {
var i: number;
for (i = 0; i < this.books.length; i++) {
console.log(i);
return this.http.get(url+this.books[i].name)
.map(res => {
if (res)
this.books[i].price = res.json();
});
}
}