Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions src/options/location.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,28 @@ export default {
}
},

// This service requires an option to define `key`. Options are proived using objects or functions
// User can sign up for the free api key at here: https://www.ip2location.io/sign-up
ip2locationio: function () {
return {
// This service responds with JSON, so we simply need to parse it and return the country code
url: 'https://api.ip2location.io/?key={api_key}&format=json',
headers: ['Accept: application/json'],
callback: function (done, response) {
try {
const json = JSON.parse(response);
return json.error ? toError(json) : {
code: json.country_code
};
} catch (err) {
return toError({
error: 'Invalid response (' + err + ')'
});
}
}
};
},

maxmind: function() {
return {
// This service responds with a JavaScript file which defines additional functionality. Once loaded, we must
Expand Down