HTTP Get Call with Header选项正在返回未经授权的错误



我在http的标题中传递access_token。

注意:我在项目中不使用HTTP Incerpector

 let header_object = {
 'Content-Type'       : 'application/json',
  'Access-Control-Allow-Origin' : '*',
  'Access-Control-Allow-Headers' : 'Origin, X-Requested-With, Content- Type, Accept',
  'Authorization' : 'bearer ' + this.token.toString().replace(/"/g, ""),
};
  httpOptions = {headers: header_object };
  // console.log(this.token);
  console.log(httpOptions);
  })
return this.http.get<JSON>(this.baseurl, httpOptions);

尝试此

    let headers = new HttpHeaders({
    'Authorization' : 'Bearer '+ token
    });
  return this.http.get<JSON>(this.baseurl, headers);

最新更新