Hi,
I’m having an error regarding http in my service class. I’ve already imported Http from @angular/http as well as rxjs/Rx and rxjs/add/operatror/map but still the error persists. Can someone please help? It will be much appreciated. TIA. Posted is my service code
import { Http } from ‘@angular/http’;
import ‘rxjs/Rx’;
import ‘rxjs/add/operator/map’;
export class RestService {
url: string;
data: any;
static get parameters(){
return [[Http]];
}
constructor(public http: Http) {
this.url = "<my backend url here>";
this.data = {};
this.data.response = "";
this.http = http;
}
doLogin(params) {
var loginUrl = this.url + "login";
var data = JSON.stringify({
email : params.usernameOrEmail,
password: params.password
});
console.log(loginUrl + "," + data);
this.http.post(loginUrl, data).subscribe(data => {
this.data.response = data.json()._body;
}, error => {
console.log("Oooops!");
});
}
doRegister(params) {
var registerUrl = this.url + "signup";
var data = JSON.stringify({email : params});
this.http.post(registerUrl, data).subscribe(data => {
this.data.response = data.json()._body;
}, error => {
console.log("Oooops!");
});
}
doConfirmEmail(params) {
var confirmEmailUrl = this.url + "confirm/email";
var data = JSON.stringify({email : params});
this.http.post(confirmEmailUrl, data).subscribe(data => {
this.data.response = data.json()._body;
}, error => {
console.log("Oooops!");
});
}
}
This is the error
EXCEPTION: Error in ./Login class Login - inline template:20:28 caused by: this.http.post is not a function