How to call API in shopify pos

shira1
Excursionist
34 0 3

We become indebted to.

I'm developing a shopify POS app (tile) and have a question about how to call the API.

Development language: react
App proxy settings: Subpath prefix = apps, subpath = testapi, proxy URL = domain of the app you are developing


I am trying to fetch the API using the App proxy and call the Discount API at the communication destination.
I fetched it, but an error occurred.

The iMac console error is:
XXXXXXXXXX Shopify POS Type: Error Timestamp: Fri, 05 Feb 2021 03:10:45 GMT Message: Error: Optional Params: [{}]

The source is here.

	testDiscount() {
		// app proxy API test
		const url = 'https://XXXXXX.myshopify.com/apps/testapi/api/test_discount';
		fetch(url)
		.then(res => res.json())
		.then((data) => {
			console.log(data);
		})
		.catch(e => {
			console.error('Error: ', e);
		});
	}



There was no log left on the app's server, so I suspect there's a problem with the url, but the iMac console doesn't show the details of the error.
In addition, the API to be called above could be called by fetch with javascript on the storefront cart screen.

Is there any other way to call the API from shopify POS?
I would appreciate it if you could teach me.

0 Likes