I am trying to get some Json from http://localhost:3000/clientes
, in Angular 5, and load it into a table.
I can just load Json in table when it is in /assets/
This is the code in general.component.ts
constructor (private httpService: HttpClient) { }
myVals: string [];
ngOnInit () {
this.httpService.get('./assets/person.json').subscribe(
data => {
this.myVals = data as string [];
},
(err: HttpErrorResponse) => {
console.log (err.message);
}
);
}
And this is the body of my table
<tr *ngFor="let item of myVals">
<td class="text-center" style="width: 15px;">{{item.ID}}</td>
<td class="text-center" style="width: 15px;">{{item.Name}}</td>
<td class="text-center" style="width: 200px;">{{item.CPF}}</td>
<td class="text-center">{{item.body}}</td>
</tr>
I am searching a lot, but nothing that could help me, so far. Thanks