# Invoke edge function on page load

**URL:** <https://community.weweb.io/t/invoke-edge-function-on-page-load/18787>\
**Category:** Developer corner\
**Tags:** supabase\
**Created:** [June 16, 2025, 6:37pm UTC](https://community.weweb.io/t/invoke-edge-function-on-page-load/18787 "2025-06-16T18:37:05Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![emdiemeric](https://avatars.discourse-cdn.com/v4/letter/e/e9bcb4/32.png) [@emdiemeric](https://community.weweb.io/u/emdiemeric)\
**Post date:** [June 16, 2025, 6:37pm UTC](https://community.weweb.io/t/invoke-edge-function-on-page-load/18787/1 "2025-06-16T18:37:06Z")

</div>

I have an edge function that return object data.

When I test it and send the following in the body:

{  
“supplierId”: “82004”  
}

I get the correct response.

In weweb, I’m not sure what is mandatory to configure and how to bind the body correctly.

I tried binding javascript to the body, but with no success:

return [{ key: ‘supplierId’, value: globalContext.pageParameters[‘id’] || ‘82004’ }]

Any advice?

 ![Screenshot 2025-06-16 at 21.35.56](https://us1.discourse-cdn.com/flex016/uploads/weweb/original/2X/a/abb24f710e4ff5eee94b08e000fa0313f4083b8d.png)

---

<div class="post-metadata">

**Author:** ![Broberto](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/broberto/32/5918_2.png) [@Broberto](https://community.weweb.io/u/Broberto)\
**Post date:** [June 16, 2025, 7:37pm UTC](https://community.weweb.io/t/invoke-edge-function-on-page-load/18787/2 "2025-06-16T19:37:33Z")

</div>

Try passing an object, not an array

---

<div class="post-metadata">

**Author:** ![emdiemeric](https://avatars.discourse-cdn.com/v4/letter/e/e9bcb4/32.png) [@emdiemeric](https://community.weweb.io/u/emdiemeric)\
**Post date:** [June 16, 2025, 7:41pm UTC](https://community.weweb.io/t/invoke-edge-function-on-page-load/18787/3 "2025-06-16T19:41:15Z")

</div>

tried this:

{  
“supplierId”: “82004”  
}

still no result

---

<div class="post-metadata">

**Author:** ![Broberto](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/broberto/32/5918_2.png) [@Broberto](https://community.weweb.io/u/Broberto)\
**Post date:** [June 16, 2025, 7:44pm UTC](https://community.weweb.io/t/invoke-edge-function-on-page-load/18787/4 "2025-06-16T19:44:03Z")

</div>

You must get some answer when testing, maybe even an error. Check out the logs

---

<div class="post-metadata">

**Author:** ![emdiemeric](https://avatars.discourse-cdn.com/v4/letter/e/e9bcb4/32.png) [@emdiemeric](https://community.weweb.io/u/emdiemeric)\
**Post date:** [June 16, 2025, 7:45pm UTC](https://community.weweb.io/t/invoke-edge-function-on-page-load/18787/5 "2025-06-16T19:45:56Z")

</div>

name: “Error”  
stack: “Error: Failed to send a request to the Edge Function at Object.invokeEdgeFunction ([https://cdn.weweb.io/components/f9ef41c3-1c53-4857-855b-f2f6a40b7186/6d5dd36e-d77a-4054-901e-806ac8c56554/dist/ma](https://cdn.weweb.io/components/f9ef41c3-1c53-4857-855b-f2f6a40b7186/6d5dd36e-d77a-4054-901e-806ac8c56554/dist/ma)…”  
message: “Failed to send a request to the Edge Function”  
cause  
name: “FunctionsFetchError”  
status: undefined  
data: undefined  
context

---

<div class="post-metadata">

**Author:** ![Bruno](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/bruno/32/14495_2.png) [@Bruno](https://community.weweb.io/u/Bruno)\
**Post date:** [June 16, 2025, 9:23pm UTC](https://community.weweb.io/t/invoke-edge-function-on-page-load/18787/6 "2025-06-16T21:23:17Z")

</div>

1. Try running it directly from your Supabase instance to see if you get a more descriptive error (if any).
2. You can try pluging in your input, expected output, actual output, and current function into some LLM and just start asking questions (e.g., why is this not working).
3. For what I see, looks like a parsing error. Maybe even from the frontend side.

---

<div class="post-metadata">

**Author:** ![Batik\_Okazov](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/batik_okazov/32/12688_2.png) [@Batik\_Okazov](https://community.weweb.io/u/Batik_Okazov)\
**Post date:** [June 17, 2025, 7:43am UTC](https://community.weweb.io/t/invoke-edge-function-on-page-load/18787/7 "2025-06-17T07:43:08Z")

</div>

Check the API call result in the browser’s DevTools \>\> “Network”

---

<div class="post-metadata">

**Author:** ![emdiemeric](https://avatars.discourse-cdn.com/v4/letter/e/e9bcb4/32.png) [@emdiemeric](https://community.weweb.io/u/emdiemeric)\
**Post date:** [June 17, 2025, 8:00am UTC](https://community.weweb.io/t/invoke-edge-function-on-page-load/18787/8 "2025-06-17T08:00:49Z")

</div>

![Screenshot 2025-06-17 at 10.59.54](https://us1.discourse-cdn.com/flex016/uploads/weweb/original/2X/7/7fff3955112fe412943e57050103daef158bec2d.jpeg)

---

<div class="post-metadata">

**Author:** ![Batik\_Okazov](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/batik_okazov/32/12688_2.png) [@Batik\_Okazov](https://community.weweb.io/u/Batik_Okazov)\
**Post date:** [June 17, 2025, 8:09am UTC](https://community.weweb.io/t/invoke-edge-function-on-page-load/18787/9 "2025-06-17T08:09:59Z")

</div>

you should clear the contents and after that make your API call. Then you will be able to inspect the result.

[![](https://us1.discourse-cdn.com/flex016/uploads/weweb/original/2X/6/6997493fa7374d54477be67b2c3e841e486fbcff.jpeg "How to inspect API calls using chrome") ](https://www.youtube.com/watch?v=o1FixYX1OUQ)

---

<div class="post-metadata">

**Author:** ![Broberto](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/broberto/32/5918_2.png) [@Broberto](https://community.weweb.io/u/Broberto)\
**Post date:** [June 17, 2025, 8:30am UTC](https://community.weweb.io/t/invoke-edge-function-on-page-load/18787/10 "2025-06-17T08:30:15Z")

</div>

This is a JavaScript error, nit a neteork error I think

---

<div class="post-metadata">

**Author:** ![Batik\_Okazov](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/batik_okazov/32/12688_2.png) [@Batik\_Okazov](https://community.weweb.io/u/Batik_Okazov)\
**Post date:** [June 17, 2025, 12:32pm UTC](https://community.weweb.io/t/invoke-edge-function-on-page-load/18787/11 "2025-06-17T12:32:29Z")

</div>

yeah, maybe. I had several workflows in my project that resulted in the same unrecognizable error inside the editor, but in the dev tools I found a real hint to solve the problem.

I don’t quite remember what the issues were (I suppose CORS issue or changing the general API endpoint URL in Xano)

---

<div class="post-metadata">

**Author:** ![emdiemeric](https://avatars.discourse-cdn.com/v4/letter/e/e9bcb4/32.png) [@emdiemeric](https://community.weweb.io/u/emdiemeric)\
**Post date:** [June 17, 2025, 5:02pm UTC](https://community.weweb.io/t/invoke-edge-function-on-page-load/18787/12 "2025-06-17T17:02:34Z")

</div>

Flo just fixed this for me on OO: the issue was in the edge function. I needed to update the CorsHeaders. I was missing some of the values.

“Access-Control-Allow-Headers”: "Content-Type, Authorization,x-client-info, apikey, content-type
