Logo-amall

functions have no response in browser

Last active 1 months ago

3 replies

6 views

  • TE

    When I hit my functions using fetch, I am getting 200, but the response is empty. I can see my logs and know that the function is getting hit and working properly in the backend, but the browser isn't getting the response. I'll post some code and screenshots. I am 100% perplexed.

  • TE
    const stuff = await fetch(
            `http://localhost:1337/v1/functions/online-store?site_id=${duda.siteDetails.siteId}&partner=square&product_type=subscription_plans`,
            {
              mode: 'no-cors',
              headers: new Headers({ 'Content-Type': 'application/json' }),
            }
          )
            .then((r) => r.json())
            .catch((err) =>
              err instanceof Error ? err : new Error(JSON.stringify(err))
            )
    
          console.log(stuff)
    
  • TE

    ok, as SOON as I post this, I take a look at the 'no-cors' setting and think, hmm, maybe I don't need that anymore… boom, it works. 🤦‍♂️

Last active 1 months ago

3 replies

6 views