Skip to content
Snippets Groups Projects
Commit 6dc86994 authored by Lewin Kästner's avatar Lewin Kästner
Browse files

remove EuFundingService

parent 2369ec37
No related branches found
No related tags found
1 merge request!157Documentation improvements and removing unused files
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Observable, of } from 'rxjs';
import { ajaxGetJSON } from 'rxjs/internal-compatibility';
import { catchError, map, take } from 'rxjs/operators';
import { MessageService } from './message.service';
@Injectable({
providedIn: 'root',
})
export class EuFundingService {
private url =
'https://ec.europa.eu/info/funding-tenders/opportunities/data/referenceData/grantsTenders.json';
constructor(private messageService: MessageService, private http: HttpClient) {}
getGrantTenders(): Observable<any> {
const header = new HttpHeaders();
const n = header.set('Access-Control-Allow-Origin', '*').set('Accept', '*/*');
/* eslint-disable @typescript-eslint/naming-convention */
return ajaxGetJSON(this.url, { 'Access-Control-Allow-Origin': '*' }).pipe(
take(1),
map((response) => response),
catchError(this.handleError<any>('grantTenders', {}))
);
}
private handleError<T>(operation = 'operation', result?: T) {
return (error: any): Observable<T> => {
// TODO: send the error to remote logging infrastructure
console.error(error); // log to console instead
// TODO: better job of transforming error for user consumption
this.messageService.log('MensaService', `${operation} failed: ${error.message}`);
// Let the app keep running by returning an empty result.
return of(result as T);
};
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment