Skip to content

Instantly share code, notes, and snippets.

@sirtimbly
Created March 26, 2018 02:38
Show Gist options
  • Save sirtimbly/20865a2597b016e810f3bbdb025a1f0a to your computer and use it in GitHub Desktop.
Save sirtimbly/20865a2597b016e810f3bbdb025a1f0a to your computer and use it in GitHub Desktop.
async network call
public getIPLocation = () => {
const context = this;
const req = axios.get("//freegeoip.net/json/")
.then((res) => {
if (res.data.region_code && res.data.region_code.length === 2) {
context.data.locationState = res.data.region_code;
}
context.renderer(context.data);
})
.catch((x) => { context.renderer(context.data); });
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment