I need a little bit help with Angular (9). I do a GET Request to fetch a list of Users from the Backend:
getUsers() {
return this.http.get<User[]>(`${this._constant.baseAppUrl}/users/all`, )
.pipe(map(user => {
return user;
}));
}
My Goal is to get an Array of Objects with a type of the User Model. Instead I get an object.
I don't understand why. My IDE also shows, that the user variable is User[], but in the browser the typeof user is "object".
So how can I get an array back?
EDIT: This is the Answer from the Backend:
{
"5ea04cfbcd595b393d78acbb": {
"isAdmin": true,
"role": "User",
"status": "cEmail",
"_id": "5ea04cfbcd595b393d78acbb",
"name": "Test",
"password": "$2b$10$re0gqblgXsfYus1mYA3yQ.Oiz4x81c3M2uxfE4tG6V7tNW1JMubXi",
"email": "[email protected]",
"__v": 0
},
"5ea1f308fc8909618668384e": {
"isAdmin": true,
"role": "User",
"status": "cEmail",
"_id": "5ea1f308fc8909618668384e",
"name": "Mathias Braun",
"password": "$2b$10$zpQezfiG4xNkwOTgV4CLIeYU4MITVfL2VhlLC3rqCbjBGl5TIpavG",
"email": "[email protected]",
"__v": 0
}
}
