这是我面临的错误: " home.ts:40错误:SyntaxError:意外的令牌{在位置2和#34的JSON中;
我使用API从数据库中获取列表中的数据。 home.ts中的第40行是err => { console.error("错误:" +错误); },
home.ts:
constructor(public navCtrl: NavController, public navParams : NavParams, public http:Http, public loadingCtrl: LoadingController, private httpProvider:HttpProvider) {
this.user_id = this.navParams.get('user_id');
this.distributor_id = this.navParams.get('distributor_id');
this.getdata(this.user_id, this.distributor_id);
}
getdata(user_id, distributor_id){
this.httpProvider.getAllData(user_id, distributor_id).subscribe(
result => {
this.newsData=result.complaint;
console.log("Success : "+this.newsData);
},
err =>{
console.error("Error : "+err);
} ,
() => {
console.log('getData completed');
}
);
}
http.ts:
getAllData(user_id, distributor_id){
var headers = new Headers();
headers.append('Content-Type', 'application/x-www-form-urlencoded');
let options = new RequestOptions({headers: headers});
let postParams ='&fse_id=' + user_id + '&distributor_id=' + distributor_id;
console.log(postParams);
return this.http.post("http://www.btedge.appexperts.net/Ionic_Webservices/type.php", JSON.stringify(postParams), options).map(res => res.json());
}
}