Discussing Shopify Functions development, deployment, and usage in Shopify apps.
Hi I'm trying to GET fetch requests using two different APIs but keep getting a CORS issue on the second fetch. I've tried writing this in different ways and also using the same API and still get the CORS issue on the second fetch request, example below of one of the requests, no point showing both requests because if if there swapped around or are identical still get same issue:
ANy help would be greatly appriecated!
useEffect(() => {
if (companyHouseMatch === true && companyHouseChecked === true) {
const url = `external API url'
fetch(
`${url}`,
{
method: 'GET',
},
).
then((response) => response.json()).then((data) => {
setValidationError("")
console.log("Records", data)
setHouseCity(data.address.city)
setPostal(data.address.postalCode)
setStreetAddress(data.address.streetAddress)
}).
catch(
(error) => {
console.error(error)
setValidationError("Not valid");
}
)
}
})
Thanks in advance