Reputation: 109
I am creating a registration component, and for some reason when I make the API call to the registration service, absolutely nothing happens. I am using a data context class to make the call to the Angular Http service.
This is in the registration service:
return this._webApiDataContext.post(registrationUrl, registration)
.map(response => { return response.json() });
This is in the data context class:
post(url: string, data: any) {
let headers = this._getHeaders();
// If the data is an object, we need to stringify it first.
if (typeof data == 'object') {
data = JSON.stringify(data);
}
return this._httpClient.post(url, data, { headers });
}
Everything works fine until it gets to this._httpClient.post(), and then nothing at all happens. I've use Fiddler to check network traffic, and it is not making the http call. I cannot for the life of me figure out why.
Also, I am using this exact same data context method for the login, and that works perfectly. So I know the data context class is working.
Upvotes: 1
Views: 280
Reputation: 657108
Observables are lazy and don't to anything without subscribe()
or toPromise()
:
post(someUrl, someData).subscribe(result => console.log(result));
Upvotes: 2