Questions tagged httpclient

Explore the latest questions and answers asked by our top developers.

Ionic5 Angular – transform http reponse to custom object

I’m completely new to Ionic and angular and I’m trying to load data from a REST api (for testing a local json file) and transform them to an object as the origin json structure is not really useful. I tried this: ngAfterViewInit(){ var data = this.locationService.getLocalData() console.log(data); } location.service.ts: getLocalData() { let url = "/assets/data/locallocations.json"; […]

By Lawrence Stiller
Published
Categorized as angular, httpclient, ionic-framework Tagged , ,

Angular map wait Observable to complete

I am trying to send httpclient in my Observable function, it will run without the HttpClient Complete. Here is a demo code which is used to reproduce test() { this.test2() .pipe( mergeMap((result) => { console.log(result[0]); return of([]); }) ) .subscribe(); } test1(): Observable<any> { return of(this.getStudents()); } test2(): Observable<any> { return this.test1().pipe( mergeMap((result) => { […]

By Edward
Published
Categorized as angular, httpclient, observable, rxjs, typescript Tagged , , , ,

Angular 12 TypeError: Cannot read properties of null (reading ‘length’) at HttpHeaders.applyUpdate

I’m getting this error message when I make a http request in my Angular Service. This only happens when I logout but when I login the error disappears: Here’s my authentication Service: import { Injectable } from ‘@angular/core’; import { HttpClient, HttpHeaders } from ‘@angular/common/http’; import { Observable, throwError } from ‘rxjs’; import { catchError, […]

By Mohid
Published
Categorized as angular, http, httpclient, rxjs, typescript Tagged , , , ,

Problem with Angular Http Client Exercise [closed]

As part if a certification that I’m working on, I have the following problems trying to do the Angular Http Client excercise, here is the link to the post I made in Coursera: https://www.coursera.org/learn/angular/discussions/weeks/4/threads/ebqOrRj7EeyQ9gqn9j-8_Q I’m using Angular 12 Source: Angular Questions

By PedroCova
Published
Categorized as angular, httpclient Tagged ,

Angular Loop over httpClient

I have a grid of multiple rows and I am doing a bulk action ‘Ex: deletion for multiple rows on 1 click’ so I am looping over the httpClient reuest. So if I have 3 rows, When the 3rd request is excuted successfully I wanna popup a single toaster saying ‘Saved Successfully’. The problem now […]

By Ziad Mohamed
Published
Categorized as angular, httpclient Tagged ,

Call script request instead of XHR using HttpClient Angular

I’m trying to call backend with URL as http://ec2-18-195-176-53.eu-central-1.compute.amazonaws.com/user/details It is a script type call instead of XHR. [screenshot added]. Now the response is javascript code. I’m calling the API like below. The reason I’m not using httpClient is that httpClient uses XHR and this starts failing because this is a script type call. getUserDetails(isBrowser: […]

return observable but wait until another finishes

I was ask to add a functionnality to a legacy code. The legacy code handle a get request with some added features like avoiding duplciate calls and cache get request when PWA is offline. In the context of this PWA when have some POST/PUT/DELETE operation I want to commit before any get is executed. I […]

By Su4p
Published
Categorized as angular, httpclient, rxjs Tagged , ,

HOW TO SEND PARAMETERS WITH GET IN HTTPCLIENT MODULE?

To send parameters i must do it in httpParams no ? I dont know why but in back id is undefined? Maybe i am doing something wrong. FRONT getUser(id: string): any { console.log(‘EFE’, id); const url = `${this.baseUrl}/auth/getUser`; let params = new HttpParams().set(‘id’, id); console.log(params); return this.http .get<AuthResponse>(url, { params }) .pipe(catchError((err) => of(err.error.msg))); } […]

By Paul Bombay
Published
Categorized as angular, get, http-parameters, httpclient Tagged , , ,

how to send raw JSON using angular 2+ like below image using angular 2+

enter image description here I am not able to send post request payload using angular for graph api . api will accept only raw json Source: Angular Questions

By Akash Gupta
Published
Categorized as angular, httpclient, json, raw Tagged , , ,

Angular 12 ConcatMap how i can do it?

I want to concat the tow api call. How i can use ConcatMap on this code ? getHIndices(code) { this.api.getInstrumentHistoryIndices(code, ‘3M’) .subscribe((response: {}) => { this.prepareDataForHistory(response); }); setTimeout(() => { this.api.getInstrumentHistoryIndices(code, ‘5Y’) .subscribe((response: {}) => { this.prepareDataForHistory2(response); }); }, 300); } Source: Angular Questions

By zakaria1153
Published
Categorized as angular, concatmap, httpclient, rxjs Tagged , , ,
1 2 3 4 5 18

Still Have Questions?


Our dedicated development team is here for you!

We can help you find answers to your question for as low as 5$.

Contact Us
faq