-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a6d6a69
commit e4aa60c
Showing
6 changed files
with
3,707 additions
and
2,210 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
language: node_js | ||
node_js: | ||
- '7' | ||
- '6' | ||
- '8' |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,18 @@ | ||
'use strict' | ||
|
||
// Packages | ||
const got = require('got') | ||
|
||
module.exports = () => | ||
got('https://ipinfo.io/json') | ||
.then(res => { | ||
const json = JSON.parse(res.body) | ||
const lat = json.loc.split(',')[0] | ||
const long = json.loc.split(',')[1] | ||
const data = Object.assign({}, json, { lat, long }) | ||
const wer = async () => { | ||
try { | ||
const { body } = await got('https://ipinfo.io/json') | ||
const json = JSON.parse(body) | ||
const lat = json.loc.split(',')[0] | ||
const long = json.loc.split(',')[1] | ||
const data = Object.assign({}, json, { lat, long }) | ||
|
||
return data | ||
} catch (error) { | ||
throw new TypeError(error) | ||
} | ||
} | ||
|
||
return data | ||
}) | ||
.catch(err => err) | ||
module.exports = wer |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,11 @@ | ||
'use strict' | ||
|
||
// Packages | ||
import test from 'ava' | ||
|
||
// Root | ||
import wer from '.' | ||
|
||
test(async t => { | ||
const result = await wer().then(res => res) | ||
const { ip, hostname, city, region, country, org, postal, lat, long } = result | ||
test('it should get ip', async t => { | ||
const result = await wer() | ||
|
||
t.truthy(ip) | ||
t.truthy(hostname) | ||
t.truthy(city) | ||
t.truthy(region) | ||
t.truthy(org) | ||
t.truthy(country) | ||
t.truthy(postal) | ||
t.truthy(lat) | ||
t.truthy(long) | ||
t.truthy(result) | ||
}) |
Oops, something went wrong.