Open History to see the last commit
1import { HttpClient } from '@angular/common/http'
2import { Injectable, inject } from '@angular/core'
3import { of } from 'rxjs'
4import type { SuggestionsResponse } from './types'
5β
6@Injectable({
7 providedIn: 'root',
8})
9export class SuggestionsAPI {
10 readonly #http = inject(HttpClient)
11β
12 getSuggestions = (term: string = '') =>
13 term.trim() === ''
14 ? of({ suggestions: [] })
15 : this.#http.get<SuggestionsResponse>(
16 `/api/autocomplete?term=${encodeURIComponent(term)}`,
17 )
18}