Skip to main content

Using real data

External requests

Shop Minis run in a restricted environment and external requests are only permitted on a case-by-case basis. They must fetch data using the minisFetch helper and domains must be listed in the trusted_domains field of the manifest. However, during development you can make requests to localhost or use fetch directly.

import {minisFetch} from '@shopify/shop-minis-platform-sdk'
try {
const res = await minisFetch('http://localhost:3000/endpoint', {
method: 'POST',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
},
body: JSON.stringify({
param: 'value',
}),
})

handleSuccess(await res.json())
} catch (error) {
handleError(error)
}
caution

There is currently no authentication mechanism for external requests. Minis should only make requests to public (i.e. unauthenticated) APIs.