Files
bizmatch-project/bizmatch/src/app/services/geo.service.ts

19 lines
658 B
TypeScript

import { Injectable } from '@angular/core';
import { environment } from '../../environments/environment';
import { Observable } from 'rxjs';
import { HttpClient } from '@angular/common/http';
export interface GeoResult { city: string; state: string; state_code: string }
@Injectable({
providedIn: 'root'
})
export class GeoService {
private apiBaseUrl = environment.apiBaseUrl;
constructor(private http: HttpClient) { }
findCitiesStartingWith(prefix:string, state?:string):Observable<GeoResult[]>{
const stateString = state?`/${state}`:''
return this.http.get<GeoResult[]>(`${this.apiBaseUrl}/bizmatch/geo/${prefix}${stateString}`);
}
}