req-country

1.2.10 • Public • Published

req-country

Last version NPM Status

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
}
  • 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

Package Sidebar

Install

npm i req-country

Weekly Downloads

38

Version

1.2.10

License

MIT

Unpacked Size

6.8 kB

Total Files

4

Last publish

Collaborators

  • kikobeats