Search
 
SCRIPT & CODE EXAMPLE
 

TYPESCRIPT

add header in angular

import {Injectable} from '@angular/core';
import {Http, Headers} from '@angular/http';

@Injectable()
export class HttpClient {

  constructor(private http: Http) {}

  createAuthorizationHeader(headers: Headers) {
    headers.append('Authorization', 'Basic ' +
      btoa('username:password')); 
  }

  get(url) {
    let headers = new Headers();
    this.createAuthorizationHeader(headers);
    return this.http.get(url, {
      headers: headers
    });
  }

  post(url, data) {
    let headers = new Headers();
    this.createAuthorizationHeader(headers);
    return this.http.post(url, data, {
      headers: headers
    });
  }
}
Comment

PREVIOUS NEXT
Code Example
Typescript :: how to use variables with if statements python 
Typescript :: withStyles(DateRangePicker) 
Typescript :: recharts bar chart 
Typescript :: reactnative upload image axios 0.66 
Typescript :: how to push an object into an array typescript 
Typescript :: html5 download tag not working angular 
Typescript :: godot preload 
Typescript :: reported error code “128” when it ended: Permission denied (publickey). fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists. 
Typescript :: styled components on vscode 
Typescript :: how to get value from autocomplete material ui 
Typescript :: what are data points 
Typescript :: how to separate elements in list python 
Typescript :: python convert a csv to a tsv 
Typescript :: count number of set bits in number java 
Typescript :: js split at index 
Typescript :: styled-components error in typescript 
Typescript :: generic arrow function typescript 
Typescript :: typescript webpack node 
Typescript :: how to get match percentage of lists in python 
Typescript :: init tsconfig file 
Typescript :: how to make a button that alerts when clicked with html 
Typescript :: typescript axios 
Typescript :: google sheets new line 
Typescript :: router params angular 
Typescript :: react-excel-renderer 
Typescript :: typescript variable types 
Typescript :: typescript err type 
Typescript :: how to install downloaded requirements pip with python 
Typescript :: path para imports firebase firestore 
Typescript :: create and use constants in angularjs 
ADD CONTENT
Topic
Content
Source link
Name
5+4 =