So this code works… sometimes:
It seems to work as long as it’s getting an API response, but it seems like that response comes in really slowly sometimes. Occasionally the code will suddenly start working after the pen is saved. Sometimes nothing happens at all. Sometimes it pops up immediately. I’ve been tinkering around but I can’t figure out what’s causing that behavior, besides just maybe the API is really slow or spotty.
Am I right about this, or is there something wrong with my code?
Comes up for me. but yes, the API can be unstable. it’s an open issue atm
either that or the Geolocation API is acting slow. this happens pretty often
Yeah, geolocation can act slow, especially on multiple calls. In chrome I’ve seen it start to be 20 second delays after a few calls, sometimes a couple minutes.
Besides just coding in the geolocation data, is there a known workaround for the geolocation delay? Or is coding it in for testing purposes the go-to?
I don’t know about the “go-to”. I think geolocation just wasn’t built with repeated testing in mind. One option is to hard code the data in for dev. Another would be to cache the data in local storage and use that until geolocation (or whatever else) comes back with a response. And of course, there are APIs that will give a user’s location, and in my experience it is pretty quick.
People default to navigator because it’s built into the browser. And it works mostly, It’s just a pain for dev where you keep trying it over and over.