Created
July 27, 2020 10:46
-
-
Save pdashford/954293c2ee395c596377d1ccb5f4fbb4 to your computer and use it in GitHub Desktop.
NodeJS Typescript function to return IP Address meta information
This file contains 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
export async function getIpMeta(ipAddr) { | |
try { | |
const url = `http://api.ipstack.com/${ipAddr}?access_key=youraccesskey` | |
const result = await request.get(url, { | |
headers: { 'content-type': 'application/json; charset=utf-8' } | |
}) | |
return JSON.parse(result) | |
} catch (e) { | |
console.error('error', e) | |
return undefined | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment