Last active
April 20, 2022 11:45
-
-
Save henryruhs/486008f5023c77536a03c037cf8e09a4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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