本文整理汇总了TypeScript中@angular/http.BaseRequestOptions.merge方法的典型用法代码示例。如果您正苦于以下问题:TypeScript BaseRequestOptions.merge方法的具体用法?TypeScript BaseRequestOptions.merge怎么用?TypeScript BaseRequestOptions.merge使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@angular/http.BaseRequestOptions
的用法示例。
在下文中一共展示了BaseRequestOptions.merge方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: it
it('create connection', () => {
let base = new BaseRequestOptions(),
request: ngRequest = new ngRequest(base.merge(new RequestOptions({ url: 'http://localhost/ok' }))),
response: ResponseOptions = new ResponseOptions({ status: HTTP_STATUS_OK });
expect(() => new FetchConnection(request, new BrowserFetch(), response)).not.toThrow();
});
示例2: beforeEach
beforeEach(() => {
TestBed.configureTestingModule({
providers: [
MockBackend,
BaseRequestOptions,
{
provide: Http,
useFactory: (mockBackend, options) => new Http(mockBackend, options),
deps: [MockBackend, BaseRequestOptions]
},
PackageService
]
});
const base = new BaseRequestOptions();
sampleRequest = new Request(base.merge(new RequestOptions({ url: 'https://google.com' })));
sampleResponses = sampleJsons.map(obj => {
return new Response(new ResponseOptions({ body: JSON.stringify(obj) }));
});
backend = TestBed.get(MockBackend);
backend.connections.subscribe(connection => {
connection.mockRespond(sampleResponses.shift());
});
});
示例3: BaseRequestOptions
import {BaseRequestOptions, Request, RequestMethod} from '@angular/http';
export const requestOptions = new BaseRequestOptions();
var req = new Request(requestOptions.merge({
method: RequestMethod.Post,
url: 'https://uoentrada.info/auth'
}));
console.log('req.method:', RequestMethod[req.method]); // Post
console.log('options.url:', requestOptions.url); // null
console.log('req.url:', req.url); // https://google.com