Angular2 http验证

时间:2017-05-03 08:49:45

标签: angular typescript

我想通过Angular2 Typescript进行身份验证,但它无法正常工作,因为它在浏览器中询问我。我的代码怎么了?

callrest(){
  let url="/edison";
  return this.http.post(url, this.getPutHeaders()).map(res => res.json()).subscribe(
               data => console.log(data),
               err => console.log(err)
            );;
}



private getPutHeaders(){
    let headers = new Headers();
    headers.append('Content-Type', 'text/plain');
    headers.append('Authorization', 'Basic ' +
      btoa('user:pw'));
    return new RequestOptions({
        headers: headers

    });
}

enter image description here

0 个答案:

没有答案