Skip to content

Instantly share code, notes, and snippets.

@pdashford
Created July 27, 2020 10:46
Show Gist options
  • Save pdashford/954293c2ee395c596377d1ccb5f4fbb4 to your computer and use it in GitHub Desktop.
Save pdashford/954293c2ee395c596377d1ccb5f4fbb4 to your computer and use it in GitHub Desktop.
NodeJS Typescript function to return IP Address meta information
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