Questions tagged [angular4-httpclient]

Use this tag only for questions related to the HttpClient service included in HttpClientModule of Angular version 4

The HttpClient service is included in HttpClientModule of Angular version 4. HttpClient can be used for establishing an HTTP communication performing requests and processing responses.

220 questions
4
votes
1 answer

Angular 4 HttpClientModule

How does this code change wrt to the new HttpClientModule, where mapping from response.json() is not required. //uses Http getLegalTerms(): Observable { return this._http.get(this._legalTermUrl) .map((response:…
Anand
  • 1,387
  • 2
  • 26
  • 48
4
votes
1 answer

Angular 4.3 HttpClient with MockBackend

I used to use HttpModule to fire ajax call and had a mockup backend to catch every request in the front-end for developing. Now I use HttpClientModule because I want to use the interceptor feature. But my mockup backend base on Http is not…
etlds
  • 5,810
  • 2
  • 23
  • 30
4
votes
1 answer

Loader Using HttpClient Interceptor Angular 4

How can i implement a loader using Angular 4 HttpClient Interceptor? I have done the login and attaching the authorization header and i wonder if i can also do the "loader function" if some data is loading in the process? I would like to attached a…
Joseph
  • 7,042
  • 23
  • 83
  • 181
4
votes
3 answers

How to read Custom error message from backend in Angular 4/2

API add(data) { return this.httpClient.post('/api/v3/templates', data); } Observable this.templateService.add(obj) .subscribe( (response) => { console.log(reposne) }, (error) => { console.log(error) } ); My Post API gives back a…
atul mishra
  • 253
  • 1
  • 6
  • 20
3
votes
1 answer

HTTP_INTERCEPTOR for specific routes in Angular 4+

I have created HTTP_INTERCEPTOR, I need it to work on some specific routes and some others not. At the begining it was in the main app module file, then I removed it from there and add it in some modules,but it still work on all routes , then i…
3
votes
3 answers

How can I pass a string to a post request in Angular?

I have done some searching and nothing seems to help. My angular looks like this with username being a string. getUser(username = null) { if (username == null) { username = this.cookie.getCookieValue("username"); } console.log(JSON.stringify({…
Lionel
  • 31
  • 1
  • 8
3
votes
1 answer

Angular 5 - Observable return error cannot read property of undefined

I'm starting to implement a simple pagination using Spring Rest and Angular 5 inside my angular service when I call my web service using httpClient a get a correct response with the requested page it's display data on my page correctly but there an…
e2rabi
  • 4,728
  • 9
  • 42
  • 69
3
votes
1 answer

ERROR TypeError: subscribe is not a function

I am trying to get value from array based on some element and then getting the exact matching element. But somehow i am facing this error for in this function getProduct(name1: string), i have imported map already. Help will be much…
Janny
  • 127
  • 1
  • 12
3
votes
1 answer

angular 4 httpGet withCredentials and header conflict

for sending cookie to server I must use { withCredentials: true } in options parameter,But When I use this.http.get(this.accountUrl + 'ExternalLoginConfirmation', { withCredentials: true }) I get the following error : Response to…
Ali Abbaszade
  • 151
  • 1
  • 2
  • 16
3
votes
1 answer

how to save id from an item to show a specific data on the next page (angular 4)

I have a school list which im getting from a web service, and a dashboard page, what i want is when the user clicks on a specific school is to open the dashboard page but it will fetch data regarding the selected school, so its kind of saving the id…
Mohamed Wahshey
  • 422
  • 1
  • 6
  • 24
3
votes
2 answers

How to map JSON response to Model in Angular 4

I have tried a lot but I am not able to get endpoint response mapped to my model. I am using HttpClient and Angular4. I got data back from service but it is not mapped correctly to my model class. I have following JSON which service is Returning:…
user2480218
  • 61
  • 1
  • 1
  • 7
3
votes
1 answer

how to set localhost path on iframe in angular 4

Hi please help to solve the code. if I embed static HTML file that is stored in my project directory the iframe is not working when i embed live URL in the iframe the iframe is working fine here my folder structure src |-app | |-components | …
MDF
  • 1,343
  • 1
  • 11
  • 14
3
votes
1 answer

Angular 4 DI : wait for method completion

To avoid cyclic dependency i am using the Injector to inject the AuthService but when i run the application Angular execute the intercept() method before setting the authService property !!! @Injectable() export class TokenInterceptorService…
SEY_91
  • 1,615
  • 15
  • 26
3
votes
2 answers

Webpack-dev-server- Module build failed

I am getting the error ---Error is below ERROR in ./src/main.ts Module build failed: [object Object] @ multi webpack-dev-server/client?http://0.0.0.0:0 ./src/main.ts ERROR in ./src/polyfills.ts Module build failed: [object Object] @ multi…
Meena Mana
  • 249
  • 1
  • 7
  • 18
3
votes
1 answer

Filtering requests in httpInterceptor - Angular 4.3+

I have an authentication interceptor, however, I want this interceptor to filter requests and not be applied when users access components like confirm account password etc which do not need user authentication. Any example on how to go about it?…
smons
  • 65
  • 1
  • 6
1 2
3
14 15