Skip to content

Instantly share code, notes, and snippets.

@ekam230
Created October 18, 2018 15:58
Show Gist options
  • Save ekam230/29efc6704c2d4e5edd4c2b7bb0cc0347 to your computer and use it in GitHub Desktop.
Save ekam230/29efc6704c2d4e5edd4c2b7bb0cc0347 to your computer and use it in GitHub Desktop.
tempor
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