IONIC / Angular 2:基于Cookie的身份验证(带标题)

时间:2017-02-16 19:31:44

标签: angular ionic-framework ionic2

我有以下代码将cookie标头传递给端点但是REST调用失败并出现错误(但错误为空)..任何人都可以看到我在下面的电话有问题吗?

import { Component } from '@angular/core';
import {Http, Headers } from '@angular/http';
import {InAppBrowser} from 'ionic-native';
import { NavController } from 'ionic-angular';
import { ThemeableBrowser } from 'ionic-native';
import {Observable} from 'rxjs/Rx';
 import 'rxjs/add/operator/map';

    @Component({
      selector: 'page-contact',
      templateUrl: 'contact.html'
    })
    export class ContactPage {

      constructor(private http: Http) {

      }



  launchTheme(url){

var headers = new Headers();
  headers.append('Cookie', 'HQ9VVdTJnJlcXVlc3RUbXN0bXA9MjAxNy0wMi0xNFQxOCUzQTQ0JTNBMzImdXNlcklkPSZwYWdlPTEmc3RhcnQ9MCZsaW1pdD0yNQ%3D%3D; CTSESSION=AAAAAgABAFhYyvOIo1rGqfd4fcbFvbxrwSCaYNMhCKtp5PJvq08KEn0890EoJrMjezIENjxp2ZEltDG4uUzdO79H2lk2kur2%2FdZu6%2FCRNvN5kztICTsEBCQ9qjjZHgAM');
 this.http.get('http://tespapi.com', {
    headers: headers
    })
    .map(res => res.text())
    .subscribe(
      data =>  console.log(data),
      err =>  console.log(err),

    );

  }

}

0 个答案:

没有答案