Skip to content

Instantly share code, notes, and snippets.

@ardydedase
Created September 30, 2021 04:02
Show Gist options
  • Save ardydedase/12606c646ffddc9f21f00699064b108e to your computer and use it in GitHub Desktop.
Save ardydedase/12606c646ffddc9f21f00699064b108e to your computer and use it in GitHub Desktop.
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { map } from 'rxjs/operators';
@Injectable()
export class GithubService {
constructor(private http: HttpClient) {}
public searchRepos(searchString) {
return this.http
.get(`https://api.github.com/search/repositories?q=${searchString}`)
.pipe(map((result) => result['items']));
}
public searchUsers(searchString) {
console.log('search users..');
return this.http
.get(`https://api.github.com/search/users?q=${searchString}`)
.pipe(map((result) => result['items']));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment