question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Need method to get Country Code by Country Name

See original GitHub issue

It would be great if we can get country code based on country name.

Something like this.

getCountryCode('US');  // +1

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
catamphetaminecommented, Apr 3, 2017

Why would you need that

0reactions
yuliankarapetkovcommented, Jul 19, 2021

Use getCountryCallingCode():

Returns country calling code for a country. Will throw an error if country doesn’t exist or isn’t supported by this library.

import { getCountryCallingCode } from 'libphonenumber-js';

getCountryCallingCode('RU') === '7'
getCountryCallingCode('IL') === '972'
Read more comments on GitHub >

github_iconTop Results From Across the Web

get country code from country name in android - Stack Overflow
name = locale.getDisplayCountry(); // Map all country names and codes in key - value pairs. countryMap.put(name, code); } ...
Read more >
countrycode: Convert Country Names and Country Codes
Convert country codes or country names. Details. The countrycode function can convert to and from several different country coding schemes.
Read more >
How to convert a country name to country code in apex?
I need to convert this country name to country code and need to send that to an external endpoint. In 'Nationality' picklist, I...
Read more >
Javascript how to get Country code from country name?
Hi, I would like to get the country code from a country name using plain vanilla javascript? United Kingdom = UK South Africa...
Read more >
Country Codes, Phone Codes, Dialing Codes, Telephone ...
COUNTRY COUNTRY CODE ISO CODES Afghanistan 93 AF / AFG Albania 355 AL / ALB Algeria 213 DZ / DZA
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found