/** * This file is part of Anis Client. * * @copyright Laboratoire d'Astrophysique de Marseille / CNRS * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ import { Injectable } from '@angular/core'; import { HttpClient } from '@angular/common/http'; import { Observable } from 'rxjs'; import { environment } from 'src/environments/environment'; @Injectable() /** * @class * @classdesc Search service. */ export class SearchService { API_PATH: string = environment.apiUrl; constructor(private http: HttpClient) { } /** * Retrieves results for the given parameters. * * @param {string} query - The query. * * @return Observable<any[]> */ retrieveData(query: string): Observable<any[]> { return this.http.get<any[]>(this.API_PATH + '/search/' + query); } /** * Retrieves results number for the given parameters. * * @param {string} query - The query. * * @return Observable<{ nb: number }[]> */ retrieveDataLength(query: string): Observable<{ nb: number }[]> { return this.http.get<{ nb: number }[]>(this.API_PATH + '/search/' + query); } }