import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';

@Injectable({
  providedIn: 'root',
})
export class AutocompleteService {
  private apiUrl = 'https://nominatim.openstreetmap.org/search';

  constructor(private http: HttpClient) {}

  getAddressSuggestions(query: string): Observable<any> {
    return this.http.get(this.apiUrl, {
      params: {
        q: query,
        format: 'json',
        addressdetails: '1',
        limit: '5',
      },
    });
  }
}
