我在IONIC 3项目中有多个http.post请求。我需要保留调用之间的会话状态。我给服务器打电话的方式如下:
this.http.post('http://192.168.1.107:7777/mobile/Open_a').
subscribe(
(data:any) =>
{
// first processing data for the first call here.
// next calling the server for the second time and passing the data back to the server
// start of second call
this.http.post('http://192.168.1.107:7777/mobile/Open_b',
{params: {clientdata:"test data"}}).
subscribe((data2:any)=>
{
console.log(data2);
},
err2 =>
{
console.log('error happened!');
console.log(err2.message);
let alert = this.alertCtrl.create({
title: 'Connection error',
subTitle: err2.message,
buttons: ['Dismiss']
});
alert.present();
}
);
// end of second call code},
err =>
{
console.log('error happened!');
console.log(err.message);
ProductDataProvider.ItemsLoaded=true;
ProductDataProvider.IsLoading=false;
let alert = this.alertCtrl.create({
title: 'Connection error',
subTitle: err.message,
buttons: ['Dismiss']
});
alert.present();
}
);
问题在于对服务器的两个调用都可以工作,但是会话状态没有保留。有人可以指出我在做什么错吗?
任何建议都将受到高度赞赏。
你真心
答案 0 :(得分:0)
仅与withCredetials:true一起使用
this.http.post(ProductDataProvider.Server +'/ mobile / index',{search:searchstr},{withCredentials:true})...