本文整理汇总了TypeScript中@angular/common/http.HttpHeaders.append方法的典型用法代码示例。如果您正苦于以下问题:TypeScript HttpHeaders.append方法的具体用法?TypeScript HttpHeaders.append怎么用?TypeScript HttpHeaders.append使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@angular/common/http.HttpHeaders
的用法示例。
在下文中一共展示了HttpHeaders.append方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: send
send(post: any) {
let the_headers = new HttpHeaders();
the_headers.append('Content-Type', 'multipart/form-data;boundary='+Math.random());
the_headers.append('Accept', 'application/json');
return this.http.post(environment.api_url + '/celty', post, {headers: the_headers})
.map(res => res);
}
示例2: loadAlbumPhoto
/**
* Load photos for specified album
* @param albumid ID of album
* @param accesscode Access code
* @param top Maximum amount of the photo to fetch
* @param skip The amount to skip in the result
*/
public loadAlbumPhoto(albumid: string | number, accesscode?: string, top?: number, skip?: number): Observable<any> {
let params: HttpParams = new HttpParams();
params = params.append('albumid', albumid.toString());
if (accesscode) {
params = params.append('accesscode', accesscode);
}
if (top) {
params = params.append('top', top.toString());
}
if (skip) {
params = params.append('skip', skip.toString());
}
let headers = new HttpHeaders();
headers = headers.append('Content-Type', 'application/json')
.append('Accept', 'application/json');
if (this._authService.authSubject.getValue().isAuthorized) {
headers = headers.append('Authorization', 'Bearer ' + this._authService.authSubject.getValue().getAccessToken());
return this._http.get(environment.PhotoAPIUrl, {
headers: headers,
params: params });
}
return this._http.get(environment.PhotoAPIUrl, {
headers: headers,
params: params,
});
}
示例3: getHeaders
/**
* This is a Global place to add all the request headers for every REST calls
*/
getHeaders():HttpHeaders {
let headers = new HttpHeaders();
let token = this.userInfoService.getStoredToken();
headers = headers.append('Content-Type', 'application/json');
if (token !== null) {
headers = headers.append("Authorization", token);
}
return headers;
}
示例4: getTagCount
/**
* Get Tag count
*/
public getTagCount(): Observable<any> {
const apistring = environment.PhotoTagCountAPIUrl;
let headers = new HttpHeaders();
headers = headers.append('Content-Type', 'application/json')
.append('Accept', 'application/json');
if (this._authService.authSubject.getValue().isAuthorized) {
headers = headers.append('Authorization', 'Bearer ' + this._authService.authSubject.getValue().getAccessToken());
}
return this._http.get(apistring, { headers: headers});
}
示例5: header
/**
* 添加Http头
* @param name 名称
* @param value 值
*/
header(name: string, value): HttpRequest<T> {
let stringValue = "";
if (value !== undefined && value !== null)
stringValue = String(value);
this.headers = this.headers.append(name, stringValue);
return this;
}
示例6: getShellToken
getShellToken(namespace: string, podName: string): Observable<any> {
let headers = new HttpHeaders();
const username = 'publicV1'
const password = 'a1b2c3d4E'
headers.append('Authorization', 'Basic ' + btoa(username + ':' + password));
headers.append('Content-Type', 'application/x-www-form-urlencoded');
const options: any = {'headers': headers};
let urlSearchParams = new HttpParams();
urlSearchParams.append('namespace', namespace);
urlSearchParams.append('podName', podName);
return this.http
.post(`/api/v1/public/shell/token`, urlSearchParams, options)
.catch(error => Observable.throw(error));
}
示例7: saveDetailInfo
/**
* Save detail info
*/
public saveDetailInfo(usrInfo: UserDetail): Observable<any> {
if (environment.LoggingLevel >= LogLevel.Debug) {
console.log('ACGallery [Debug]: Entering method saveDetailInfo of UserDetailService...');
}
let headers = new HttpHeaders();
headers = headers.append('Content-Type', 'application/json')
.append('Accept', 'application/json')
.append('Authorization', 'Bearer ' + this._authService.authSubject.getValue().getAccessToken());
const jdata: any = JSON && JSON.stringify(usrInfo);
if (this._infoLoaded) {
// Change
const apichgurl = environment.UserDetailAPIUrl + '/' + this._authService.authSubject.getValue().getUserID();
return this._http.put(apichgurl, jdata, { headers: headers }).pipe(map((value: any) => {
this._infoLoaded = true;
this._usrdetail = usrInfo;
}));
} else {
// Create
return this._http.post(environment.UserDetailAPIUrl, jdata, { headers: headers }).pipe(map((value: any) => {
this._infoLoaded = true;
this._usrdetail = usrInfo;
}));
}
}
示例8: readDetailInfo
/**
* Read detail ifno.
*/
public readDetailInfo(): Observable<any> {
if (environment.LoggingLevel >= LogLevel.Debug) {
console.log('ACGallery [Debug]: Entering method readDetailInfo of UserDetailService...');
}
let headers = new HttpHeaders();
headers = headers.append('Content-Type', 'application/json')
.append('Accept', 'application/json')
.append('Authorization', 'Bearer ' + this._authService.authSubject.getValue().getAccessToken());
const apiurl = environment.UserDetailAPIUrl + '/' + this._authService.authSubject.getValue().getUserID();
return this._http.get(apiurl, { headers: headers })
.pipe(map((response: any) => {
this._infoLoaded = true;
this._usrdetail = new UserDetail();
this._usrdetail.onSetData(response);
return this._usrdetail;
}),
catchError((error: HttpErrorResponse) => {
if (error) {
// Log the error?
}
this._infoLoaded = false;
return of(undefined);
}));
}
示例9: getAuthWithParams
getAuthWithParams(url, params?): Observable<any> {
console.log(params);
let headers = new HttpHeaders();
headers = headers.append('Authorization', 'Basic ' + btoa('token:' + this.tokenService.getToken()));
return this.httpClient.get(url, {headers: headers, params: params});
}
示例10: HttpHeaders
postJson<T>(url: string, json: any) {
const header = new HttpHeaders();
header.append('Content-Type', 'application/json;charset=UTF-8');
return this.http.post<T>(url, json, {
headers: header,
withCredentials: true
});
}