Skip to content

Instantly share code, notes, and snippets.

@henryruhs
Last active April 20, 2022 11:45
Show Gist options
  • Save henryruhs/486008f5023c77536a03c037cf8e09a4 to your computer and use it in GitHub Desktop.
Save henryruhs/486008f5023c77536a03c037cf8e09a4 to your computer and use it in GitHub Desktop.
import { HttpClient, HttpParams } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { RequestBody, ResponseBody } from './example.interface';
import { environment } from '@env';
@Injectable()
export class ExampleService
{
protected apiUrl : string = environment.apiUrl;
protected endpoint : string = environment.routes.example;
constructor(protected http : HttpClient)
{
}
findByIdArray(idArray : string[]) : Observable<ResponseBody[]>
{
let params : HttpParams = new HttpParams();
idArray.map(id => params = params.append('id', id));
return this.http.get<RequestBody[]>(this.apiUrl + this.endpoint,
{
params
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment