Seeking assistance with my Angular project - a beginner in programming looking for guidance on retrieving images from a web API.
- ASP.NET Framework Web API 4.7
- Angular CLI: 13.3.7
- Angular: 13.3.11
On the Web API side:
Controller:
[EnableCors(origins: "*", headers: "*", methods: "*")]
public class HomeController : ApiController
{
// Code snippet here...
}
Models:
HomeModel class:
// Code snippet here...
Motorcycle class:
// Code snippet here...
DTO class:
// Code snippet here...
On the Angular side:
Model:
home-categorised-bikes.model.ts:
// TypeScript code snippet here...
Service:
home-categorised-bikes.service.ts:
// TypeScript code snippet here...
app.component.ts:
// TypeScript code snippet here...
app.component.html:
<div class="container">
<h4>{{title}}</h4>
<div *ngFor="let bikeImg of bikesImgs">
<img [src]="bikeImg">
</div>
Swagger:
https://i.sstatic.net/Z1MRo.png
Error:
Response.forEach is not a function at AppComponent.onHomeBikesImgsResponse (app.component.ts)
Appreciate any help provided. Thank you.