import { HttpClient } from '@angular/common/http' ; import { Injectable } from '@angular/core' ; import { Observable } from 'rxjs' ; import { environment } from '../environments/environment' ; import { User } from './user' ; import { Repository } from './repository' ; import { Organization } from './organization' ; @ Injectable ( { providedIn : 'root' } ) export class GithubService { private userUrl : string = '' ; constructor ( private http ) { this . userUrl = `${ environment . apiUrl }/users/${ environment . username }` ; } getUser ( ) { return this . http . get < User > ( this . userUrl ) ; } getRepos ( ) { return this . http . get < Repository [ ] > ( this . userUrl + '/repos' ) ; } getOrganizations ( ) { return this . http . get < Organization [ ] > ( this . userUrl + '/orgs' ) ; } }