added Photon Service & interface

This commit is contained in:
Janis Meister
2022-01-14 09:29:17 +01:00
parent 682e3017ad
commit a1150cabdd
4 changed files with 65 additions and 2 deletions

18
src/app/photon.service.ts Normal file
View File

@@ -0,0 +1,18 @@
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Photon } from './interfaces/photon';
import { Observable } from 'rxjs';
@Injectable({
providedIn: 'root'
})
// communicates with Photon (https://photon.komoot.io/)
export class PhotonService{
constructor(private http: HttpClient) { }
// sends a query request to Photon and gets response (https://photon.komoot.io/)
sendQueryRequest(q: string): Observable<Photon[]> {
return this.http.get<Photon[]>("https://photon.komoot.io/api/?q=" + q);
}
}