@swordslinger wrote:
Im currently building a simple weather app, I have a service set up take data from open weather API, take in current location coordinates via geolocations in the home page.ts and want to be able too sub them in for {lat} and {lon} into the API url so it pulls weather from you current location, and I am unsure how too go about doing this,any help would be appreciated
this is the service.ts file
import { Injectable } from ‘@angular/core’;
import { HttpClient} from ‘@angular/common/http’
import {Observable} from ‘rxjs’
import { Geolocation } from ‘@ionic-native/geolocation/ngx’;@Injectable({
providedIn: ‘root’
})export class WeatheredataService {
constructor(private httpClient: HttpClient) { }
public getWeather():Observable{
return this.httpClient.get('http://api.openweathermap.org/data/2.5/weather?lat{lat}8&lon{lon}&appid=fec30507acb533f670080ab3174f226f') }
}
Posts: 1
Participants: 1