本文整理匯總了TypeScript中@angular/http.RequestOptions.merge方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript RequestOptions.merge方法的具體用法?TypeScript RequestOptions.merge怎麽用?TypeScript RequestOptions.merge使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類@angular/http.RequestOptions
的用法示例。
在下文中一共展示了RequestOptions.merge方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: sendRequest
private sendRequest(url: string, options: RequestOptionsArgs): Observable<string> {
// make a copy
let options1 = new RequestOptions();
options1.method = options.method;
options1 = options1.merge(options);
let resource = this.adalService.GetResourceForEndpoint(url);
let authenticatedCall: Observable<string>;
if (resource) {
if (this.adalService.userInfo.isAuthenticated) {
authenticatedCall = this.adalService.acquireToken(resource)
.flatMap((token: string) => {
if (options1.headers == null) {
options1.headers = new Headers();
}
options1.headers.set('Authorization', 'Bearer ' + token);
return this.http.request(url, options1)
.catch(this.handleError);
});
}
else {
authenticatedCall = Observable.throw(new Error('User Not Authenticated.'));
}
}
else {
authenticatedCall = this.http.request(url, options).map(this.extractData).catch(this.handleError);
}
return authenticatedCall;
}
示例2: requestHelper
private requestHelper(requestArgs: RequestOptionsArgs, additionalOptions?: RequestOptionsArgs): Observable<Response> {
let options = new RequestOptions(requestArgs);
if (additionalOptions) {
options = options.merge(additionalOptions);
}
return this.request(new Request(options));
}
示例3: head
/**
* Get Head
* @param endPoint
* @param options
* @returns {Observable<Response>}
*/
public head(endPoint: string, options?: RequestOptions) : Observable<Response>{
let _options:RequestOptions = ApiAuth.createHttpOptions();
_options.url = Config.apiUrl + endPoint;
_options.method = RequestMethod.Head;
if (options) {
_options = _options.merge(options);
}
return this.requestHelper(_options)
}
示例4: patch
/**
* Patch a Resource
* @param endPoint
* @param body
* @param options
* @returns {Observable<Response>}
*/
public patch(endPoint: string, body: any, options?: RequestOptions) : Observable<Response>{
let _options:RequestOptions = ApiAuth.createHttpOptions();
_options.url = Config.apiUrl + endPoint;
_options.method = RequestMethod.Patch;
_options.body = JSON.stringify(body);
if (options) {
_options = _options.merge(options);
}
return this.requestHelper(_options)
}
示例5: find
/**
* Find a Resource
* @param endPoint
* @param params
* @param additionalOptions
* @returns {Observable<Response>}
*/
public find(endPoint: string, params:URLSearchParams, options?:RequestOptions) : Observable<Response>{
let _options:RequestOptions = ApiAuth.createHttpOptions();
_options.url = Config.apiUrl + endPoint;
_options.method = RequestMethod.Get;
_options.search = params;
if (options) {
_options = _options.merge(options);
}
return this.requestHelper(_options);
}
示例6: _request
_request(options: RequestOptionsArgs, auth?: boolean) {
if (auth) {
if (localStorage.getItem(this._config.tokenName)) {
this.defaultOptions.headers.set('Authorization', 'Bearer ' + localStorage.getItem(this._config.tokenName))
} else {
}
}
options.url = `${this.API_ENDPOINT}${options.url}`
return this.http.request(new Request(this.defaultOptions.merge(options)))
.map((res: any) => res.json())
}
示例7: requestHelper
private requestHelper(additionalOptions?:RequestOptions){
this.loading.start(() => {
});
let options:RequestOptions = ApiAuth.createHttpOptions();
if (additionalOptions) {
options = options.merge(additionalOptions);
}
let req = this.http.request(new Request(options));
req.subscribe(res => this.HandleReponse(res), error => this.HandleError(error));
return req;
}
示例8: mergeOptions
private mergeOptions(options?: RequestOptionsArgs): RequestOptionsArgs {
const csrfToken: string = this.cookieService.get('XSRF-TOKEN');
let base: RequestOptions = new RequestOptions({
headers: new Headers({
'Content-Type': 'application/json',
'X-Requested-With': 'XMLHttpRequest',
'X-XSRF-TOKEN': csrfToken
})
});
// If we have a valid jwt token, we add it
if (this.tokenService.isValid()) {
base.headers.set('Authorization', 'Bearer ' + this.tokenService.token.access_token);
}
return base.merge(options);
}
示例9: requestHelper
private requestHelper(requestArgs: RequestOptionsArgs, additionalOptions?: RequestOptionsArgs): Observable<Response> {
console.log("Handling options...");
let options = new RequestOptions(requestArgs);
if (additionalOptions) {
options = options.merge(additionalOptions);
}
if (this.boxConfig.boxTokenCache) {
return this.boxConfig.boxTokenCache.getToken()
.mergeMap((token) => {
return this.requestWithToken(new Request(this.mergeOptions(options, this.defOpts)), token);
})
} else {
return this.boxConfig.refreshTokenFunction()
.mergeMap((token) => {
console.log("Refreshing token...");
console.log(token.json());
return this.requestWithToken(new Request(this.mergeOptions(options, this.defOpts)), token.json());
});
}
}
示例10: delete
delete(url) {
return this.http
.delete(url, this.defaultOptions.merge({ url }))
.map(ShHttpService.onResponseSuccess);
}