Closed hannosch closed 8 years ago
NEVER MIND, FIXED.
I am having some trouble:
var GEO_URL = 'https://location.services.mozilla.com/v1/country?key=fcce8909-53a6-4d26-83da-e822cdf4ac13';
fetch(GEO_URL).then((r)=>console.log(r.json))
The url seems to work fine. Maybe I don't understand fetch
:)
FIX: r.json() is a promise.
@hannosch, take a look over this. If you claim that this is ready for projection, I am happy to switch it over immediately.
@hannosch
Thanks for doing this!
GL
@gregglind
As I said on IRC, we won't have a problem with taking the extra traffic. We took on snippets earlier this year which also all Firefox users and caches in local storage for 30 days. I'd expect the traffic from this to match snippets.
Hanno
@gregglind this also references #181. We talked about various long term options to expose country data from a central place inside the browser. But for the short term we want to shut down geo.mozilla.org and switch everyone to MLS.
The MLS API is documented at https://mozilla.github.io/ichnaea/api/region.html, though the simplest way is to do a GET request, like:
curl https://location.services.mozilla.com/v1/country?key=fcce8909-53a6-4d26-83da-e822cdf4ac13
and get a status code 200 JSON response, with a body of:
{ "country_code": "US", "country_name": "United States", "fallback": "ipf" }
In failure cases 4xx and 5xx status codes can be returned, not all of them necessarily containing JSON in the body.
The API key here is only used to identify the consuming service/website, so we can collect metrics about their individual usage and attribute back problems to the right caller. The key in the curl example is meant to be used by self-repair. It can be put into a public repo and be shared across dev/stage/prod sites.
For another code example of the snippets service switching over see:
https://github.com/mozilla/snippets-service/pull/143/files#diff-3adb3669370af06c37adc916ba7b7c3cL398