Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/**
* 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 }[]>
*/
getDataLength(query: string): Observable<{ nb: number }[]> {
return this.http.get<{ nb: number }[]>(this.API_PATH + '/search/' + query);
}
}