Join us for an upcoming Shopify Partner webinar on February 27, 2024. Discover the latest Checkout Extensibility features, and deep dive on improvements to Shopify Functions and Web Pixels. Register now for either the 10am EST or 2pm EST sessions.

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

Tom_Hooker
Shopify Expert
83 4 11

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)