Сохранение состояния сеанса между запросами IONIC 3 http.post - PullRequest
0 голосов
/ 12 ноября 2018

У меня несколько запросов http.post в проекте IONIC 3. Мне нужно сохранить состояние сеанса между вызовами. Я звоню на сервер следующим образом:

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();
  }

);

проблема в том, что оба вызова к серверу работают, но состояние сеанса не сохраняется. Кто-нибудь может указать, что я делаю неправильно?

Любой совет высоко ценится.

твой искренне

1 Ответ

0 голосов
/ 09 декабря 2018

просто используйте withCredetials: true

this.http.post (ProductDataProvider.Server + '/ mobile / index', {search: searchstr}, {withCredentials: true}) ...

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...