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
91
votes
4 answers

Default and specific request timeout

Usually it's desirable to have default timeout (e.g. 30s) that will be applied to all requests and can be overridden for particular longer requests (e.g. 600s). There's no good way to specify default timeout in Http service, to my knowledge. What is…
Estus Flask
  • 206,104
  • 70
  • 425
  • 565
54
votes
9 answers

ERROR Error: StaticInjectorError(AppModule)[UserformService -> HttpClient]:

While trying to add a PrimeNG table I broke my build here: https://github.com/BillyCharter87/Tech-O-Dex-UI/tree/BrokeIt I recall updating my package.json from TypeScript 2.3.4 to 2.4.0 and it broke due to (I think) the fact that I was using Headers…
Billy
  • 1,049
  • 3
  • 14
  • 23
19
votes
10 answers

Angular 4: "Http failure response for (unknown URL): 0 Unknown Error"

I am trying to consume an API URL. I am calling the API with the below code. import {HttpClient, HttpClientModule, HttpParams} from "@angular/common/http"; @Injectable() export class PropertyPrefService { constructor(private http: HttpClient, …
user8300647
  • 335
  • 2
  • 4
  • 10
19
votes
3 answers

How to post a string in the body of a post request with Angular 4.3 HttpClient?

We've got a .net WebAPI which looks for a filepath string in the body of a post request and returns the corresponding image. I'm struggling to successfully pass a string to it from Angular 4.3 using the new httpClient. Is it possible? The endpoint's…
user3302396
  • 311
  • 1
  • 2
  • 7
18
votes
4 answers

Interceptors only for specific Service

I have several services in my app that point to different API URLs. Now I need to set different headers to each of these services. My question is now regarding the new interceptors in Angular 4. Is there a possibility to set one interceptor for a…
Tom
  • 201
  • 1
  • 2
  • 3
16
votes
1 answer

Untyped function calls may not accept type arguments - Angular 5 http calls

I'm trying to fetch data from API using interface. Bellow is my temp interface export interface ITemp { id: number, name: string, age: number } And below is my HTTP service, where there is a fn getHomedetails, which calls an…
13
votes
2 answers

Passing Typescript "Map" as a part of Angular4 HTTP POST request

I have an Angular 4 Project where I am creating a sample Map as follows: let sampleMap = new Map(); sampleMap.set('key1','value1'); Now I am passing this Map as a parameter to a Angular 4 Post method which connects to a Spring Boot…
KaustubhN
  • 195
  • 1
  • 2
  • 11
12
votes
1 answer

What does multi:true mean in providers in angular4

I am using HTTP_INTERCEPTORS in angular4. For this, I have created HttpServiceInterceptor class that implements HttpInterceptor interface and provide the defintion for intercept method. Then registered provider for HTTP_INTERCEPTORS like…
Sunil Garg
  • 14,608
  • 25
  • 132
  • 189
11
votes
2 answers

Can't have a timeout of over 2 minutes with this.http.get?

My angular 4.3.2 code is calling my back-end service that takes 2-4 minutes to return. Using just the default this.http.get code, I see that the default timeout kicks in after 2 minutes. However when I try to put in a timeout of anything OVER 2…
Mike K.
  • 543
  • 3
  • 14
  • 46
11
votes
1 answer

HttpHeaders and lazyupdate Angular 4 and Karma

I have a problem with HttpHeaders (angular 4.3.0) and Karma. I write some tests and when I run them with npm test command, the http queries are unauthorized because the token (X-Auth-Token) is not set. when I run the same part in my browser with the…
Joe Allen
  • 1,267
  • 4
  • 24
  • 41
9
votes
3 answers

415 (Unsupported Media Type) angular 4 Post

I am trying to access a wep api with angular 4 post method. In my service, I've added content-type of application/json. And I'm converting the object into json while sending data to api. I am using HttpClientModule import { Injectable } from…
Jaowat Raihan
  • 271
  • 2
  • 3
  • 13
8
votes
3 answers

how to solve Circular dependency detected using Angular 4?

I am using Angular 4 simple form,Getting error when i compile the project using command line,How to solve the warning.see Error Image 1: https://i.stack.imgur.com/N1AH4.png > WARNING in Circular dependency detected: > …
Ajith Deivam
  • 736
  • 4
  • 11
  • 27
7
votes
1 answer

Angular 4, difference between httpClient and HttpClientModule

In this article here and others :It looks like you need to import HttpClientModule in app.module.ts and HttpClient in app.component.ts to make a http request. Why? How do they work?
theMobDog
  • 1,251
  • 3
  • 13
  • 26
7
votes
2 answers

Angular.io interceptors vs service workers

I want to better understand options to implement offline-friendly webapps and I read this article here: https://angular.io/guide/http which also talks about angular's interceptors. Now I am a bit puzzled: On one hand we have service workers (that…
Sergey Rudenko
  • 8,809
  • 2
  • 24
  • 51
6
votes
1 answer

Angular httpClient returns property does not exist on object

constructor(private http: HttpClient) { } ngOnInit() { this.http.get('url').subscribe(data => { console.log(data); console.log(data.login); }); } } Here, I can see the data with login in console but I get an error saying…
Ravi Yadav
  • 637
  • 1
  • 9
  • 21
1
2 3
14 15