Issue
I changed my API REST and when i swap, she don't print the informations.
My Api send me this json structure :
{
"Data": [
{
"Id": "#AJUST",
"Nom": "TRONY",
"Prenom": "JACOB",
}
]
}
I make this request with angular :
getEmployee(){
return this.http.get<any>(this.localUrlAPI+"/salarie/GetAllEmployee")
.pipe(map((res:any)=>{
return res;
}))
}
getAllEmployee(){
this.api.getEmployee()
.subscribe(res=>{
this.EmployeeData = res;
})
}
Why did that print me nothing in my application. Thx for the time that you take to help me.
Solution
Since you want to get the array in Data
, with map
rxjs operator to get res.Data
instead of res
.
map((res: any) => {
return res.Data;
})
getEmployee() {
return this.http.get<any>(this.localUrlAPI+"/salarie/GetAllEmployee").pipe(
map((res: any) => {
return res.Data;
})
);
}
And would suggest specifying EmployeeData
as array type rather than any
.
EmployeeData!: any[];
Answered By - Yong Shun
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.