Created
March 26, 2018 02:38
-
-
Save sirtimbly/20865a2597b016e810f3bbdb025a1f0a to your computer and use it in GitHub Desktop.
async network call
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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