Have your say in Community Polls: What was/is your greatest motivation to start your own business?
Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

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)