-2
ngOnInit() {
  this.allusers = [];
  this.authService.getallUsers(this.allusers)
  .subscribe(
    (response) =>console.log(response),
    (error) =>console.log(error)
  );
  console.log(this.users);
}

I am trying to load all the users(first_name,last_name and email) . I am getting the results like given below

"[{"id":"1","first_name":"renuka","last_name":"nayer","email":"renuka@gmail.com"},{"id":"2","first_name":"renuka","last_name":"nayer","email":"renuka134@gmail.com"},{"id":"3","first_name":"renuka","last_name":"nayer","email":"renuka123@gmail.com"},{"id":"4","first_name":"Rakesh","last_name":"R","email":"rakeshjack7@gmail.com"},{"id":"5","first_name":"Rakesh","last_name":"R","email":"rakeshjack7+01@gmail.com"}]"

Kindly help to get the records

Igor
  • 60,821
  • 10
  • 100
  • 175

1 Answers1

1
http
  .get('Some Url')
  .map(res => {
      return res.json(); 
  })
  .subscribe(
    (data) => this.data = data, // Reach here mapped data
    (err) => this.error = err); // fail

for shorthen, use map method to get data.

Kutlu Ozel
  • 182
  • 1
  • 7