Skip to content

Instantly share code, notes, and snippets.

@touhidrahman
Created January 30, 2022 04:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save touhidrahman/ec6cb2dbf5e2f4b4099e8f291e54abbb to your computer and use it in GitHub Desktop.
Save touhidrahman/ec6cb2dbf5e2f4b4099e8f291e54abbb to your computer and use it in GitHub Desktop.
Friends API service
import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { environment } from '@environment/environment';
import { Observable } from 'rxjs';
import { Friend } from '../models/friend';
@Injectable({
providedIn: 'root',
})
export class FriendApiService {
private apiUrl = environment.apiUrl;
constructor(private http: HttpClient) {}
getFriends(search: string = '', page = 0): Observable<Friend[]> {
return this.http.get<Friend[]>(`${this.apiUrl}/friends`, {
params: { search, page },
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment