req-country
v1.2.10
Published
Given a request, get the country code. ISO 3166-1 alpha-2 compliant.
Downloads
106
Maintainers
Readme
req-country
Given a request, get the country associated with it. ISO 3166-1 alpha-2 compliant.
Install
$ npm install req-country --save
Usage
const requestCountry = require('req-country')
module.exports = (req, res) => {
const country = requestCountry(req)
console.log({ country })
// => { country: 'ES' }
}
You can combine it with is-european
and country-vat
:
const { eeaMember, euMember } = require('is-european')
const requestCountry = require('req-country')
const countryVat = require('country-vat')
module.exports = (req, res) => {
const country = requestCountry(req)
console.log({ eeaMember: eeaMember(country), euMember: euMember(country) })
// => { eeaMember: true, euMember: true }
console.log(countryVat(country))
// => 0.21
}
Related
- is-european – Check if a country is part of the EU (European Union) or EEA (European Economic Area). ISO 3166-1 compliant.
- country-vat – Given a request, get the country associated with it. ISO 3166-1 alpha-2 compliant.
- tom.js.org – tom 🐶 is a backoffice for your projects.
License
req-country © Kiko Beats, released under the MIT License. Authored and maintained by Kiko Beats with help from contributors.
kikobeats.com · GitHub Kiko Beats · Twitter @Kikobeats