Skip to content

Instantly share code, notes, and snippets.

@cartant
Last active August 9, 2017 00:37
Show Gist options
  • Save cartant/2f7c7bdcfad5f409bd3821025877e424 to your computer and use it in GitHub Desktop.
Save cartant/2f7c7bdcfad5f409bd3821025877e424 to your computer and use it in GitHub Desktop.
@Injectable()
export class UserSearchService {
constructor(private _http: Http) {}
searchUsers(username: string): Observable<User[]> {
return username ?
this._http.get(`https://api.github.com/search/users?q=${username}`)
.map(response => response.json())
.map(content => content.items) :
Observable.of<User[]>([]);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment