import { Injectable } from "@angular/core" ; import { HttpClient , HttpHeaders } from "@angular/common/http" ; @ Injectable ( ) export class MyHttpGetService { private serverUrl = "https://httpbin.org/get" ; constructor ( private http ) { } getData ( ) { let headers = this . createRequestHeader ( ) ; return this . http . get ( this . serverUrl , { headers : headers } ) ; } private createRequestHeader ( ) { let headers = new HttpHeaders ( { "AuthKey" : "my-key" , "AuthToken" : "my-token" , "Content-Type" : "application/json" , } ) ; return headers ; } }