Thank you for your answer and comment. As I want to add additional code, I answer the question rather than add a comment. My main intention doing such a request is to add HttpParams (or rather an object representing all additional parameters to my get request) to the request.
Here is the service method:
getListProduitImmobilierDTO(pagesize: number, page: number, params: HttpParams): Observable<ProduitImmobilierDTO[]> {
const headerDict = {
'Content-Type': 'application/json',
Accept: 'application/json',
'Accept-Charset': 'charset=UTF-8',
'Access-Control-Allow-Headers': 'Content-Type'
};
return this.http.get('/api/produitimmobilier/all/' + pagesize + '/' + page, new HttpHeaders(headerDict), { observe: 'response' }, params).pipe(map((jsonArray: any) => jsonArray.map((jsonItem: object) => ProduitImmobilierDTO.fromJson(jsonItem))));
}
As you can see yazantahhan, I added { observe: 'response' } in place of HttpObserve, and it indicates the following error:
Expected 1-2 arguments, but got 4.
Sorry alt255, but I can't provide a reproducible example as it is a request and it needs a server to respond to the request. What I can tell you is the following method works well:
getListProduitImmobilierDTO(pagesize: number, page: number): Observable<ProduitImmobilierDTO[]> {
const headerDict = {
'Content-Type': 'application/json',
Accept: 'application/json',
'Accept-Charset': 'charset=UTF-8',
'Access-Control-Allow-Headers': 'Content-Type'
};
const requestOptions = {
headers: new HttpHeaders(headerDict)
};
return this.http.get('/api/produitimmobilier/all/' + pagesize + '/' + page, requestOptions).pipe(map((jsonArray: any) =>jsonArray.map((jsonItem) => ProduitImmobilierDTO.fromJson(jsonItem))));
}