Hey there, I've been away from coding for a while and now I'm diving back into Angular 8 (not exactly loving it at the moment). When I run 'ng serve' everything seems fine, but when I try to build, I keep running into an error.
userD() {
// TODO User Angular Service will get to that later.
var aToken = localStorage.getItem('token');
const headers = new HttpHeaders().set("Authorization", "Bearer " + aToken);
this.httpClient.get( 'http://127.0.0.1:8000/api/auth/user', { headers } )
.subscribe((res: any[]) => {
// @ts-ignore
this.users = res.data.result; // The build doesn't like this '.data.result' part
console.log(this.users);
});
}
Right now I'm using //@ts-ignore as a workaround, but I don't understand why it's having trouble accessing the array if I just use 'res'. Any insights would be greatly appreciated. Thank you.
NOTE: EDIT Here is the JSON data: I want to extract the 'result' object in order to loop through it using 'For' in the HTML: {"status":"200", "data": {"result":{"id":3,"name":"patrick lord","email":"[email protected]","email_verified_at":null,"phone":"123456789","profilePic":71,"created_at":"2019-09-19 19:43:04","updated_at":"2019-09-19 19:43:04","stripe_id":null,"card_brand":null,"card_last_four":null,"trial_ends_at":null,"gender":"male","Address1":"i don't live here S","Address2":"232","City":"Clearfield","Country":"USA","Zip_Post":"55550","YouTube"}}}