Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
loadMenu(): Observable {
if (!this.menu$) {
this.menu$ = this.coreWebService
.requestView({
method: RequestMethod.Get,
url: this.urlMenus
})
.pipe(
publishLast(),
refCount(),
pluck('entity')
);
}
return this.menu$;
}
getVideosById(videosId: string) {
const videosByIdUrl =
CONSTANT.VIDEO_API +
'?part=snippet,contentDetails,status,player' +
'&id=' + videosId +
'&key=' + CONSTANT.KEY_API;
return this._http
.request(videosByIdUrl, {method: RequestMethod.Get, headers: new Headers()})
.map((res) => res.json());
}
}
get(url: string, options?: RequestOptionsArgs): Observable {
let options1 = new RequestOptions({ method: RequestMethod.Get });
options1 = options1.merge(options);
return this.sendRequest(url, options1);
}
request(request: RequestOptions): Observable {
request.method = (request.method || RequestMethod.Get);
request.url = (request.url || '');
request.headers = (request.headers || {});
request.data = (request.data || {});
request.params = (request.params || {});
request.apiName = (request.apiName || this._defaultApiName);
this._interpolateUrl(request);
this._addContentType(request);
this._addAuthToken(request);
return this.http.request(
new Request({
method: request.method,
url: this._buildApiUrl(request),
backend.connections.subscribe((connection: MockConnection) => {
const options = new ResponseOptions({
body: JSON.stringify(dataToSend)
});
connection.mockRespond(new Response(options));
expect(connection.request.method).toEqual(RequestMethod.Get);
expect(connection.request.headers.get('Content-Type')).toEqual('application/json');
});
constructor(
req: Request,
baseResponseOptions: ResponseOptions,
ngZone: NgZone,
@Optional() @Inject(ORIGIN_URL) originUrl: string = '',
@Optional() @Inject(BASE_URL) baseUrl?: string) {
if (req.method !== RequestMethod.Get) {
throw new TypeError(JSONP_ERR_WRONG_METHOD);
}
this.request = req;
baseUrl = baseUrl || '/';
if (originUrl === null) {
throw new Error('ERROR: Please move ORIGIN_URL to platformProviders');
}
let _reqInfo: any = url.parse(url.resolve(url.resolve(originUrl, baseUrl), req.url));
_reqInfo.method = RequestMethod[req.method].toUpperCase();
if (isPresent(req.headers)) {
_reqInfo.headers = {};
getLastNotifications(): Observable {
return this.coreWebService.request({
method: RequestMethod.Get,
url: this.urls.getLastNotificationsUrl
});
}
constructor(
req: Request,
baseResponseOptions: ResponseOptions,
ngZone: NgZone,
@Optional() @Inject(ORIGIN_URL) originUrl: string = '',
@Optional() @Inject(APP_BASE_HREF) baseUrl?: string) {
if (req.method !== RequestMethod.Get) {
throw new TypeError(JSONP_ERR_WRONG_METHOD);
}
this.request = req;
baseUrl = baseUrl || '/';
if (originUrl === null) {
throw new Error('ERROR: Please move ORIGIN_URL to platformProviders');
}
let _reqInfo: any = url.parse(url.resolve(url.resolve(originUrl, baseUrl), req.url));
_reqInfo.method = RequestMethod[req.method].toUpperCase();
if (isPresent(req.headers)) {
_reqInfo.headers = {};
private makeApiRequest(): Promise {
let opts = this._httpClient.getOptions(RequestMethod.Get, "/", null);
return this._httpClient.request("/", opts);
}
backend.connections.subscribe((c: MockConnection) => {
expect(c.request.method).toBe(RequestMethod.Get);
expect(c.request.url).toMatch(`${API_USERS_URL}/${userId}/tracks`);
expect(c.request.url).toMatch(CLIENT_ID_PARAM);
});