本文整理汇总了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);
}