Created
October 18, 2018 15:58
-
-
Save ekam230/29efc6704c2d4e5edd4c2b7bb0cc0347 to your computer and use it in GitHub Desktop.
tempor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Http } from '@angular/http'; | |
import { Injectable } from '@angular/core'; | |
import { map } from 'rxjs/operators'; | |
@Injectable() | |
export class UsersService { | |
constructor(private http: Http) { } | |
url = 'https://randomuser.me/api/?inc=gender,name,picture,location&results=8&nat=gb/7)'; | |
getUsers() { | |
return this.http.get(this.url) | |
.pipe(map(response => response.json())) | |
.pipe(map(response => response.results)) | |
.pipe(map(users => { | |
return users.map(u => { | |
return { | |
name: u.name.first + ' ' + u.name.last, | |
geo: u.location.city + '' + u.location.state + '' + u.location.street, | |
image: u.picture.large | |
}; | |
}); | |
})); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment