Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
getAreas(): Observable {
// get the current iteration url from the space service
if (this._currentSpace) {
let areasUrl = this._currentSpace.relationships.areas.links.related;
if (this.checkValidUrl(areasUrl)) {
return this.http
.get<{data: AreaModel[]}>(areasUrl)
.pipe(
map(response => {
return response.data as AreaModel[];
}),
map((data) => {
this.areas = data;
return this.areas;
}),
catchError((error: Error | any) => {
if (error.status === 401) {
//this.auth.logout(true);
} else {
console.log('Fetch area API returned some error - ', error.message);
return Promise.reject([] as AreaModel[]);
}
})
);
} else {
this.logger.log('URL not matched');
return ObservableOf([] as AreaModel[]);
}
} else {
return throwError('nospace');
}
}
if (id === 0) {
// Clear any selection
this.currentMovie = null;
return of(this.initializeMovie());
}
if (this.movies) {
const foundItem = this.movies.find(item => item.id === id);
if (foundItem) {
return of(foundItem);
}
}
const url = `${this.moviesUrl}/${id}`;
return this.http.get(url)
.pipe(
tap(data => console.log('Data: ' + JSON.stringify(data))),
catchError(this.handleError)
);
}
// Close QR Code Modal
WalletConnectQRCodeModal.close();
result.next(true);
});
return result;
}),
switchMap(() => fromPromise(this.connector.getAccounts()))
) as unknown) as Observable;
} else {
result = ((fromPromise(
this.connector.getAccounts()
) as unknown) as Observable).pipe(
timeout(1000),
catchError(error => this.connect(true))
);
}
this.connector.on("disconnect", (error, payload) => {});
return result;
}
options(server: Server, url: string, options?: JsonOptions): Observable {
options = this.getJsonOptions(options);
const intercepted = this.getOptionsForServer(server, url, options);
return this.http
.options(intercepted.url, intercepted.options)
.pipe(catchError(this.errorHandler.handleError)) as Observable;
}
loadAboutInfo(reload?: boolean): Observable {
if (!this.aboutInfo || reload) {
this.httpClient
.get(this.aboutUrl)
.pipe(
map(this.extractData.bind(this)),
catchError(this.errorHandler.handleError)
).subscribe();
}
return of(this.aboutInfo);
}
switchMap(({ payload }) =>
loadConverterModule$.pipe(
map(converterModule => {
const converter = new converterModule.default.Converter();
return convertMdToHtml(converter.makeHtml(payload));
}),
catchError(err => of(failure(err)))
)
)
public getWikipagePreview(contents: string): Observable {
if (!environment.production) {
return new Observable(observer => {
observer.next('<p>This is a <i>preview</i></p>');
observer.complete();
});
}
const headers = new HttpHeaders()
.append('Content-Type', 'text/html; charset=utf-8')
.append('Accept', 'text/html');
return this.http.post(this.wikipagesPreviewUrl, contents, { responseType: 'text' , headers })
.pipe(
catchError(err => {
this.handleError(err);
return [];
})
);
}
getNamePictures(): Observable {
return this.http.get(`${this.baseUrl}/name-pictures`)
.pipe(
catchError((response: Response) => {
this.messageService.reportMessage(response);
throw response;
})
);
}
}
getAccounts (date?: Date): Observable {
this.log.debug('API getAccounts()');
let url = this.url + '/orgs/' + this.orgId + '/accounts';
if(date) {
url += '?date=' + date.getTime();
}
return this.http.get(url, this.httpOptions)
.pipe(catchError(this.handleError));
}
case 'PUT': {
result$ = this.http.put(url, data, options);
if (this.saveDelay) {
result$ = result$.pipe(delay(this.saveDelay));
}
break;
}
default: {
const error = new Error('Unimplemented HTTP method, ' + method);
result$ = throwError(error);
}
}
if (this.timeout) {
result$ = result$.pipe(timeout(this.timeout + this.saveDelay));
}
return result$.pipe(catchError(this.handleError(req)));
}