Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/260.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在Angular 4/5中,php getallheaders()函数的等价物是什么?_Php_Angular_Http Headers - Fatal编程技术网

在Angular 4/5中,php getallheaders()函数的等价物是什么?

在Angular 4/5中,php getallheaders()函数的等价物是什么?,php,angular,http-headers,Php,Angular,Http Headers,在Angular 4/5中,php getallheaders()函数的等价物是什么 我需要获取请求头,但在Angular中找不到 我只能获得带有角度的响应标题。请求: 看这里: 拦截器: 导出类拦截器实现HttpInterceptor{ 构造函数(){} 拦截(请求:HttpRequest) http .get('/data.json',{observe:'response'}) .订阅(resp=>{ console.log(resp.headers);//日志响应头 }); 当应用程序启动

在Angular 4/5中,php getallheaders()函数的等价物是什么

我需要获取请求头,但在Angular中找不到


我只能获得带有角度的响应标题。

请求:

看这里:

拦截器:

导出类拦截器实现HttpInterceptor{
构造函数(){}
拦截(请求:HttpRequest)

http
.get('/data.json',{observe:'response'})
.订阅(resp=>{
console.log(resp.headers);//日志响应头
});

当应用程序启动localhost:4200时,我正在寻找请求头
export class Interceptor implements HttpInterceptor {

    constructor() { }
    intercept(request: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
        console.log(request.headers); // log request headers
        let headers = request.headers // here you can get your headers
            .set('Content-Type', 'application/json')); 

        const cloneReq = request.clone({ headers });

        return next.handle(cloneReq);
    }
}
http
  .get<MyJsonData>('/data.json', {observe: 'response'})
  .subscribe(resp => {
    console.log(resp.headers); // log response headers
  });