Failed to retrieve Countries list from Shopify API, when triggering from my own domain

New Member
2 0 0

Hi Team,

 

I am trying to pull the countries list(through API) on my checkout page, but it fails to retrieve due to CORS. I can get the countries data when am trigger from Shopify domain(xxxxx.myshopify.com), however it fails when am triggering from my own domain. Kindly Suggest. 

0 Likes
Highlighted
Shopify Staff
Shopify Staff
610 83 89

Hey @Snalla,

 

Which endpoint are you hitting to get the countries? And what do you need them for? Consider pulling the countries in liquid.

0 Likes
Highlighted
New Member
2 0 0

Hi Scottydont,

 

We have custom address fields in payment_method(checkout) page and we are triggering this API (admin/api/2019-07/countries.json). We are appending the custom address html elements dynamically from JavaScript. It works when we are triggering the API with Shopify domain. But it fails to retrieve on our own domain.

 

Thanks,

Sangeethkumar N

0 Likes
Highlighted
Shopify Staff
Shopify Staff
610 83 89

Thanks for the information. Hitting that API from the client side will reveal secret API credentials.

 

You'll want to proxy the request through an app, or find another way to get the list of countries.

0 Likes