本文整理匯總了TypeScript中@angular/http.Headers.get方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript Headers.get方法的具體用法?TypeScript Headers.get怎麽用?TypeScript Headers.get使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類@angular/http.Headers
的用法示例。
在下文中一共展示了Headers.get方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: setTimeout
setTimeout(()=>{
expect(auth.isOrgApiKeySet).toBeTruthy();
let headers = new Headers();
auth.appendHeaders(headers);
expect(headers.get('Authorization')).not.toBeNull();
login.activate('');
// update both
login.onApiKeySet(SAMPLE_API_KEY, true);
headers = new Headers();
auth.appendHeaders(headers);
expect(headers.get('Authorization')).toBe(SAMPLE_AUTHORIZATION);
expect(settings.organizationApiKey).toBe(SAMPLE_API_KEY);
}, EVENT_WAIT_MILLIS);
示例2: savePhoto
savePhoto(projectId:number, stepId:number, photoToSave:Photo, header: Headers) {
delete photoToSave.file; //the file won't be updated, so we need to remove it from the body of the request
let body = JSON.stringify(photoToSave);
if (header.get('Content-Type')!='application/json')
header.append('Content-Type', 'application/json');
return this.http.put(this.uploadPhotoUrl + projectId + "/step/" + stepId + "/update/" + photoToSave.id + "/" ,
body, {
headers: header
})
.map((responseData) => {
let photo = responseData.json();
header.delete('Content-Type');
return new Photo(
photo.id,
photo.created,
photo.file,
photo.position,
photo.step,
photo.isProjectPhoto
);
});
}
示例3: saveStep
saveStep(projectID:number, stepToSave:Step, header: Headers) {
let body = JSON.stringify(stepToSave);
if (header.get('Content-Type')!='application/json')
header.append('Content-Type', 'application/json');
if (stepToSave.id!=null) { //update
return this.http.put(this.baseUrl + "steps/update/" + stepToSave.id + "/" ,
body, {
headers: header
})
.map((responseData) => {
let step = responseData.json();
header.delete('Content-Type');
return new Step(step.id, step.position, step.title, step.content, step.project);
});
}
console.log()
return this.http.post(this.listProjectsUrl + stepToSave.project + "/steps/add/",
body, {
headers: header
})
.map((responseData) => {
let step = responseData.json();
header.delete('Content-Type');
return new Step(step.id, null, step.title, step.content, step.project);
});
}
示例4: get
get(): Observable<string[]> {
let headers = new Headers();
//headers.append('Content-Type', 'application/json');
headers.append('Accept', 'application/json');
console.log(headers.get('Accept')); //'image/jpeg'
let options = new RequestOptions({ headers: headers });
return this.http.get('http://rxnav.nlm.nih.gov/REST/Ndfrt/search?conceptName=aspirin')
.map((res: Response) => res)
.catch(this.handleError);
}
示例5: header
public header(headerName: string): string {
return this.headers.get(headerName);
}