Angular 6中的HTTP标头

时间:2018-08-27 13:19:37

标签: header angular6

这是我正在使用的服务... 请求标头不显示任何访问授权。

import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { HttpErrorResponse, HttpHeaders } from '@angular/common/http';
import {Http, Headers, RequestOptions} from '@angular/http';

import { Config } from "../config";


@Injectable()
export class HomeService {

   headers: any;
   options: any;

    constructor(private http: HttpClient) { 
        this.headers = new Headers({'Content-Type':'application/json'});
        this.headers.append('Authorization', 'Bearer ' + localStorage.getItem('userToken'));
        this.options = new RequestOptions({headers: this.headers});
   }

    getLoginUserDetails(){
         return this.http.post(Config.apiEndPoint + "get-login-user", { headers: this.options});
    }

}

有什么解决办法让我知道吗?

0 个答案:

没有答案