Errors if weather location setting string is empty
roborourke opened this issue · comments
When you first check out the repo and load it up it errors out pretty quickly as there's no weather_location
value by default.
I've been playing with the following code in components/Weather.jsx:componentDidMount
but so far I've not been successful in getting it to actually refetch the weather condition despite it finding the coords and a place ID.
if (!this.props.location) {
if ("geolocation" in navigator) {
navigator.geolocation.getCurrentPosition(position => {
this.props.onLocationChange(position.coords.latitude + ',' + position.coords.longitude);
this.updateWeather();
});
} else {
this.props.onLocationChange(prompt('Enter your location', 'London, UK'));
this.updateWeather();
}
}
Probably a nicer / better place to put the above but not sure why it's refusing to update yet.
Should probably handle whatever's causing the error; the idea is that it should show ??º
if you don't have a location. There's some code there right now to handle that, but it's not working great.
Yeah, it's where you set the item
variable. If the weather API fails it's
still sending a valid object thinking your place ID was the string
"undefined"
@sanchothefat Should be mostly fixed now, but we can still do better defaults. Want to open a new ticket for the geolocation? :)
Will do 👍
Robert O'Rourke
mobile: +447816329424
skype: *rob.o.rourke
*web: röb.co