How to use the @angular/http.Headers function in @angular/http

To help you get started, we’ve selected a few @angular/http 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 sebastianhaas / medical-appointment-scheduling / src / app / api / api / appointment.service.ts View on Github external
public appointmentExistsHeadAppointmentsid(id: string, extraHttpRequestParams?: any): Observable {
        const path = this.basePath + `/appointments/${id}`;

        let queryParameters = new URLSearchParams();
        let headers = new Headers(this.defaultHeaders.values()); // https://github.com/angular/angular/issues/6845
        // verify required parameter 'id' is not null or undefined
        if (id === null || id === undefined) {
            throw new Error('Required parameter id was null or undefined when calling appointmentExistsHeadAppointmentsid.');
        }

        // to determine the Content-Type header
        let consumes: string[] = [
            'application/json', 
            'application/x-www-form-urlencoded', 
            'application/xml', 
            'text/xml'
        ];

        // to determine the Accept header
        let produces: string[] = [
            'application/json',
github ovh / cds / ui / src / app / service / http-service.service.ts View on Github external
getRequestOptionArgs(options?: RequestOptionsArgs): RequestOptionsArgs {
        if (options == null) {
            options = new RequestOptions();
        }
        if (options.headers == null) {
            options.headers = new Headers();
        }

        // ADD user AUTH
        let sessionToken = this._authStore.getSessionToken();
        if (sessionToken) {
            options.headers.append(this._authStore.localStorageSessionKey, sessionToken);
        } else {
            let user = this._authStore.getUser();
            if (user != null) {
                options.headers.append('Authorization', 'Basic ' + user.token);
            }
        }
        return options;
    }
}
github RoyPlu / Flare / src / app / services / tinder.service.ts View on Github external
cloudmersiveDetect(form: FormGroup) {
        const headers = new Headers({
            'ApiKey': '59710ec3-24ee-4d4c-a90e-efb6170e2f50',
        });

        const options = new RequestOptions({
            headers: headers
        });

        console.log("cloudmersiveDetect");
        console.log(this.http.post("https://api.cloudmersive.com/image/recognize/describe", form ,options).map(res => res.json()));
        return this.http.post("https://api.cloudmersive.com/image/recognize/describe", form ,options).map(res => res.json());
    }
github liimaorg / liima / AMW_angular / io / src / app / base / base.service.ts View on Github external
public postHeaders() {
    const headers = new Headers();
    headers.append('Content-Type', 'application/json');
    headers.append('Accept', 'application/json');
    return headers;
  }
github chihu-team / chihu2 / src / pages / found / found.ts View on Github external
getdata() {
    this.UserService.presentLoadingDefault();
    let url = "https://www.devonhello.com/chihu2/share";

    var headers = new Headers();
    headers.append('Content-Type', 'application/x-www-form-urlencoded');

    this.http.post(url, "len=" + this.data.length, {
      headers: headers
    })
      .subscribe((res) => {
        this.data = this.data.concat(res.json());
        this.UserService.presentLoadingDismiss();
        if( this._refresher ){
          this._refresher.complete();
        }
      });
  }
github sangwonl / stage34 / frontend / src / app / services / stage.service.ts View on Github external
public getStageLog(id: number) {
        let url = `${STAGE34_API_BASE}/stages/${id}/log/`;
        let headers = new Headers();
        this.setAuthorizationHeader(headers);
        return this.http.get(url, { headers: headers })
            .toPromise()
            .then(response => response.json().data)
            .catch(this.handleError);
    }
github tooleks / photo-blog / frontend / src / shared / services / api / api.service.ts View on Github external
protected getDefaultHeaders(): Headers {
        const defaultHeaders = new Headers;
        const rawDefaultHeaders = this.getRawDefaultHeaders();
        for (let name in rawDefaultHeaders) {
            if (rawDefaultHeaders.hasOwnProperty(name)) {
                defaultHeaders.append(name, rawDefaultHeaders[name]);
            }
        }
        return defaultHeaders;
    }
github DistributedSystemsGroup / zoe / zoe_fe / app / services / api.service.ts View on Github external
login(username: string, password: string): Promise {
        var headers = new Headers();
        headers.append('Authorization', 'Basic ' +
            btoa(username + ':' + password));

        return this.http.get(this.baseUrl + this.executionEndpoint, { headers: headers })
            .toPromise()
            .then(response => this.loginHandler(username, headers, response))
            .catch(this.handleError);
    }
github chihu-team / chihu2 / src / pages / question / question.ts View on Github external
getlist() {
    
    let url = "https://www.devonhello.com/chihu2/answer_list";

    var headers = new Headers();
    headers.append('Content-Type', 'application/x-www-form-urlencoded');

    this.http.post(url, "id=" + this._id, {
      headers: headers
    })
      .subscribe((res) => {
        this.items = res.json();
        
      });
  }
github lanit-tercom-school / studit / webroot / src / app / services / teacher.service.ts View on Github external
deleteProject(id: string, token: string) {
    let headers = new Headers();
    headers.append('Accept', 'application/json')
    headers.append('Bearer-token', token);
    return this.http.delete(environment.apiUrl + '/v1/project/id/' + id, { headers: headers });
  }
}