Shopify Checkout UI extension GET fetch issue + Fetch API + App extension + React

Shopify Checkout UI extension GET fetch issue + Fetch API + App extension + React

Tom_Hooker
Shopify Partner
84 4 12

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

On The Road Shopify Agency
Helping Shopify stores to become greater with purpose behind design.
info@ontheroaduk.co.uk
http://ontheroaduk.co.uk/
Replies 0 (0)