I'm new to Angularjs. I need to send post request to my localhost server. But I got an error [ts] cannot find name 'map' and cannot find name 'subscribe'. i hope will understand my error . Thanks in advance.
login.ts
import { Component } from '@angular/core';
import { IonicPage, NavController, NavParams } from 'ionic-angular';
import { Http ,Headers ,HttpModule} from '@angular/http';
import 'rxjs/add/operator/map';
/**
* Generated class for the Login page.
*
* See http://ionicframework.com/docs/components/#navigation for more info
* on Ionic pages and navigation.
*/
@IonicPage()
@Component({
selector: 'page-login',
templateUrl: 'login.html',
})
export class Login {
constructor(public navCtrl: NavController, public navParams: NavParams,public http:Http) {
}
ionViewDidLoad() {
console.log('ionViewDidLoad Login');
}
ionViewidData(){
let headers= new Headers();
headers.append('Content-Type','application/json');
let body = {
device:"Mobile",
id:"10077",
password:"leechan2"
};
console.log(body);
this.http.post('http://0.0.0.0:2800/login',JSON.stringify(body),{headers:headers});
.map(res => res.json())
.subscribe(data =>{
console.log(data);
});
}
}
you have an unexpected ;
at line this.http.post
.
this.http.post('http://0.0.0.0:2800/login',JSON.stringify(body),{headers:headers}) // <--------- remove ; here
.map(res => res.json())
.subscribe(data =>{
console.log(data);
});