Skip to content

Instantly share code, notes, and snippets.

@pdashford
Created July 27, 2020 10:46
Show Gist options
  • Select an option

  • Save pdashford/954293c2ee395c596377d1ccb5f4fbb4 to your computer and use it in GitHub Desktop.

Select an option

Save pdashford/954293c2ee395c596377d1ccb5f4fbb4 to your computer and use it in GitHub Desktop.

Revisions

  1. pdashford created this gist Jul 27, 2020.
    12 changes: 12 additions & 0 deletions general.helper.ts
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,12 @@
    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
    }
    }