import { Injectable } from '@angular/core' ; import { Observable } from 'rxjs' ; import { ApiService } from './api.service' ; import { Profile } from '../models' ; import { map } from 'rxjs/operators' ; @ Injectable ( ) export class ProfilesService { constructor ( private apiService ) { } get ( username ) { return this . apiService . get ( '/profiles/' + username ) . pipe ( map ( ( data ) => data . profile ) ) ; } follow ( username ) { return this . apiService . post ( '/profiles/' + username + '/follow' ) ; } unfollow ( username ) { return this . apiService . delete ( '/profiles/' + username + '/follow' ) ; } }