0

I'm trying to retrieve data from firebase using angular httpClient
firebase database


my code to get the data :
Service

getUsers() {
return this.http.get(this.fireBase+"/users.json").map(res => {
  const data = res;
  return data;
});

Component

getUsers() {
this.getWeather.getUsers().subscribe(
  (response: any) => {
    console.log(response);
  },
  err => console.log(err)
)
}

the result is :
result in the console


what I want is to get those objects without keys . I was trying to push them in array. but failed.
can anyone help please.
thanks in advance.

1 Answer 1

2

I fixed this problem by converting the object to array
here's the code :

getUsers() {
this.getWeather.getUsers().subscribe(
  (res: any) => {
    this.users = Object.keys(res).map((key) => { return res[key] });
    console.log(this.users);
  }
)
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.