How to use the @angular/common/http.HttpHeaders function in @angular/common

To help you get started, we’ve selected a few @angular/common examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github OpenTOSCA / ui / src / app / core / service / deployment-completion.service.ts View on Github external
injectNewHosts(serviceTemplateURL: string, completionSelection: any): Promise {
        const postURL = new Path(serviceTemplateURL)
            .append('injector')
            .append('replace')
            .toString();
        const httpOptions = {
            headers: new HttpHeaders({
                'Content-Type': 'application/json'
            }),
            observe: 'response'
        };
        this.logger.log('[deployment-completion.service][injectNewHosts][request-url]', JSON.stringify(postURL));

        // Todo See how to implement observe: 'response' application-management.service line 166
        // @ts-ignore
        return this.http.post>(postURL, completionSelection, httpOptions)
            .toPromise()
            .then(response => {
                const injectedserviceTemplateURL = response.headers.get('Location') as string;
                this.logger.log('[deployment-completion.service][injectNewHosts][response-location]', response.headers.get('Location'));
                return injectedserviceTemplateURL;
            });
    }
github little-pinecone / jwt-spring-boot-angular-scaffolding / frontend / src / main / angular / src / app / auth / services / token.service.spec.ts View on Github external
describe('TokenService', () => {
  let injector: TestBed;
  let service: TokenService;
  let httpMock: HttpTestingController;
  let apiUrl = environment.apiUrl;
  let HttpResponseMock: HttpResponse = {
    body: null,
    type: null,
    clone:null,
    status: 200,
    statusText: null,
    url: null,
    ok: true,
    headers: new HttpHeaders({ 'authorization': 'bearer token' })
  };

  beforeEach(() => {
    TestBed.configureTestingModule({
      providers: [TokenService],
      imports: [ HttpClientTestingModule ]
    });
    injector = getTestBed();
    service = injector.get(TokenService);
    httpMock = injector.get(HttpTestingController);
  });

  afterEach(() => {
    httpMock.verify();
  });
github kubernetes / dashboard / src / app / frontend / common / services / global / globalsettings.ts View on Github external
save(settings: GlobalSettings): Observable {
    const httpOptions = {
      method: 'PUT',
      headers: new HttpHeaders({
        'Content-Type': 'application/json',
      }),
    };
    return this.http_.put(this.endpoint_, settings, httpOptions);
  }
github ProgrammeVitam / vitam / sources / ihm-demo / ihm-demo-front / src / app / common / upload / upload.service.ts View on Github external
uploadReferentials(collection: string, file: any) {
    let header = new HttpHeaders();
    header = header.set('Content-Type', 'application/octet-stream').set('X-Filename', file.name);
    if ('ontologies'==collection){
     header = header.set('Force-Update', 'true');
    }
    return this.resourcesService.post(collection, header, file, 'text');
  }
github Azure / Azure-AppServices-Diagnostics-Portal / AngularApp / projects / applens / src / app / shared / services / diagnostic-api.service.ts View on Github external
private _getHeaders(path?: string, method?: HttpMethod, internalClient: boolean = true, internalView: boolean = true, emailRecipients: string = "",
    additionalParams?: any): HttpHeaders {
    let headers = new HttpHeaders();
    headers = headers.set('Content-Type', 'application/json');
    headers = headers.set('Accept', 'application/json');
    headers = headers.set('x-ms-internal-client', String(internalClient));
    headers = headers.set('x-ms-internal-view', String(internalView));

    if (environment.adal.enabled){
      headers = headers.set('Authorization', `Bearer ${this._adalService.userInfo.token}`)
    }

    if (this.GeomasterServiceAddress)
    headers = headers.set("x-ms-geomaster-hostname", this.GeomasterServiceAddress);

    if (emailRecipients !== "") {
      headers = headers.set('x-ms-emailRecipients', emailRecipients);
    }
github Angular2Guy / AngularAndSpring / src / angular / trader / src / app / services / bitstamp.service.ts View on Github external
limitations under the License.
 */
import { Injectable } from '@angular/core';
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { Observable } from 'rxjs';
import { catchError, map, tap } from 'rxjs/operators';
import { QuoteBs } from '../common/quoteBs';
import { QuoteCb } from '../common/quoteCb';
import { QuoteIb } from '../common/quoteIb';
import { Utils } from './utils';
import { OrderbookBs } from '../common/orderbookBs';

@Injectable({providedIn: 'root'})
export class BitstampService {    
   
    private _reqOptionsArgs = { headers: new HttpHeaders().set( 'Content-Type', 'application/json' ) };
    private readonly _bitstamp = '/bitstamp';    
    BTCEUR = 'btceur';
    ETHEUR = 'etheur';
    LTCEUR = 'ltceur';
    XRPEUR = 'xrpeur';
    BTCUSD = 'btcusd';
    ETHUSD = 'ethusd';
    LTCUSD = 'ltcusd';
    XRPUSD = 'xrpusd';
    private _utils = new Utils(); 

    constructor(private http: HttpClient) { 
    }

    getCurrentQuote(currencypair: string): Observable {
        return this.http.get(this._bitstamp+'/'+currencypair+'/current', this._reqOptionsArgs).pipe(catchError(this._utils.handleError('getCurrentQuote')));
github Hughp135 / angular-5-chat-app / src / app / services / api.service.ts View on Github external
get(url: string, options: HttpOptions = {}): Observable {
    return this.http.get(`${this.BASE_URL}${url}`, {
      headers: new HttpHeaders(options.headers),
      params: new HttpParams({ fromObject: options.query }),
    });
  }
github orange-alliance / the-orange-alliance / src / app / providers / ftc-database.ts View on Github external
return new Promise((resolve, reject) => {
      const authHeader = new HttpHeaders({
        'X-Application-Origin': 'TOA-WebApp-1819',
        'Content-Type': 'application/json'
      });
      this.http.get(this.baseURL + url, { headers: authHeader }).subscribe((data: any[]) => {
        resolve(data);
      }, (err: any) => {
        reject(err);
      });
    });
  }
github adorsys / XS2A-Sandbox / oba-ui / src / app / services / psupis.service.ts View on Github external
pisAuthUsingGETResponse(params: PSUPISService.PisAuthUsingGETParams): __Observable<__StrictHttpResponse> {
    let __params = this.newParams();
    let __headers = new HttpHeaders();
    let __body: any = null;
    if (params.redirectId != null) __params = __params.set('redirectId', params.redirectId.toString());
    if (params.encryptedPaymentId != null) __params = __params.set('encryptedPaymentId', params.encryptedPaymentId.toString());
    let req = new HttpRequest(
      'GET',
      this.rootUrl + `/pis/auth`,
      __body,
      {
        headers: __headers,
        params: __params,
        responseType: 'json'
      });

    return this.http.request(req).pipe(
      __filter(_r => _r instanceof HttpResponse),
      __map((_r) => {
github skycoin / skywire / static / skywire-manager-src / src / app / services / api.service.ts View on Github external
private getRequestOptions(options: RequestOptions) {
    const requestOptions: any = {};

    requestOptions.headers = new HttpHeaders();

    if (options.requestType === RequestTypes.Json) {
      requestOptions.headers = requestOptions.headers.append('Content-Type', 'application/json');
    }

    return requestOptions;
  }