Post Undefined HttpClient
See original GitHub issueHi there,
i recently upgraded from V7 to V8 using the guide provided.
Prior to this i was using HttpClient for my post requests and it went along fine.
After the update i get a TypeError: Cannot read property 'post' of undefined
i’ve been over the code a dozen times and for the life of me i can’t seem to find what’ is wrong with it.
import { Injectable } from '@angular/core';
import { HttpClient, HttpHeaders } from '@angular/common/http';
@Injectable({
providedIn: 'root'
})
constructor(private httpClient: HttpClient) {}
GetCountry(): Observable<any> {
return this.httpClient.post(
this.apiURL + '/country/list',
JSON.stringify({
api_key: this.apiKey
}),
this.httpOptions
);
}
Thanks
Issue Analytics
- State:
- Created 4 years ago
- Reactions:3
- Comments:13 (6 by maintainers)
Top Results From Across the Web
HttpClient instance is undefined in Angular 6 service
1. When injecting the httpClient, it's a private rather than public constructor(private http: HttpClient) { } · 2. I think you need to...
Read more >httpClient is undefined : r/Angular2 - Reddit
I've been getting an error in my browsers terminal when it attempts to execute a very short, simple function that does an http...
Read more >Communicating with backend services using HTTP - Angular
An app can send PUT requests using the HTTP client service. The following HeroesService example, like the POST example, replaces a resource with...
Read more >HttpClient - Angular
Constructs an observable for a generic HTTP request that, when subscribed, fires the request through the chain of registered interceptors and on to...
Read more >Angular Basics: How To Use HttpClient in Angular - Telerik
options – It is used to configure the HTTP request. It is optional and of type object , and its default value is...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
thanks for your suggestion @maxigimenez i reverted to a commit before the v8 update, cleared npm cache cleared node modules did a npm install and then a ng update it all worked out well after that
Try a fresh install of package.json also clearing npm cache and removing
node_modules
.