Get the country list
Dynamically get the country list, which can be used for front-end login page country selection and international SMS input box selection to reduce the size of front-end static resources.
Method name
AuthenticationClient.getCountryList
Request parameters
| Name | Type | Required | Default value | Description | Sample value |
|---|
Sample code
ts
import { AuthenticationClient, Models } from "authing-node-sdk";
const authenticationClient = new AuthenticationClient({
// Need to replace with your GenAuth AppId, Secret and Host
appId: "GEN_AUTH_APP_ID",
appSecret: "GEN_AUTH_APP_SECRET",
appHost: "GEN_AUTH_APP_HOST",
});
(async () => {
const result = await authenticationClient.getCountryList();
console.log(JSON.stringify(result, null, 2));
})();Request response
Type: GetCountryListRespDto
| Name | Type | Description |
|---|---|---|
| statusCode | number | Business status code, which can be used to determine whether the operation is successful, 200 means success. |
| message | string | Description |
| apiCode | number | Segment error code, which can be used to get the specific error type. |
| requestId | string | Request ID. Returned when the request fails. |
| data | array | response data |
Sample result:
json
{
"statusCode": 200,
"message": "Operation successful",
"requestId": "934108e5-9fbf-4d24-8da1-c330328abd6c",
"data": {
"alpha2": "CN",
"alpha3": "CHN",
"phoneCountryCode": "+86",
"flag": "🇨🇳",
"name": {
"zh-CN": {
"enabled": false,
"value": "中国"
},
"en-US": {
"enabled": false,
"value": "China"
}
}
}
}Data structure
CountryDetailInfo
| Name | Type | Is it required? | Description | Sample value |
|---|---|---|---|---|
| alpha2 | string | Yes | Alpha-2 abbreviation of the country in ISO 3166 international standard | CN |
| alpha3 | string | Yes | Alpha-3 abbreviation of the country in ISO 3166 international standard | CHN |
| phoneCountryCode | string | Yes | Country mobile phone area code | +86 |
| flag | string | Yes | Flag icon | 🇨🇳 |
| name | Yes | Name, multi-language structure, currently only supports Chinese and English Nested type: <a LangObject. | {"zh-CN":{"enabled":false,"value":"中国"},"en-US":{"enabled":false,"value":"China"}} |
LangObject
| Name | Type | Is it required | Description | Sample value |
|---|---|---|---|---|
| zh-CN | Yes | Multi-language Chinese content Nested type: <a LangUnit. | {"enabled":false,"value":"中文"} | |
| en-US | Yes | Multilingual English content Nesting type: <a LangUnit. | {"enabled":false,"value":"English"} | |
| zh-TW | Yes | Multilingual Traditional Chinese content Nesting type: <a LangUnit. | {"enabled":false,"value":"繁體中文"} | |
| ja-JP | Yes | Multilingual Japanese content Nesting type: <a LangUnit. | {"enabled":false,"value":"日本語"} |
LangUnit
| Name | Type | Is it required? | Description | Sample value |
|---|---|---|---|---|
| enabled | boolean | yes | Whether it is enabled. If enabled, and the console selects this language, the content will be displayed. (Off by default) | |
| value | string | yes | Multilingual content |