How to fetch webhook functions?

Hi i’m trying to modify some data in my database, using a webhook function with a mutation.

When i test it from my comand line with invoke-local and invoke it works ok, but when i try to send a fetch request from my app it doesn’t work.

I don’t get any [info] in the 8base logs with the event.body.json() but that isn’t still working.

This is my webhook function.

  body:JSON.stringify({,check:!check}),//<=HOW TO SEND THIS??
  headers: {
 //succes action...
  //error action...

Can someone help me please?

Hey there!

Couple things.

  1. event.body would be a string, which doesn’t have a .json() method. Instead, you’d want to do JSON.parse(event.body)

  2. Make sure you return a statusCode in your response. Like, statusCode: 200.

Other than that, as long as your query/mutation matches your data mode, it should work!

Use 8base describe in the CLI to make sure you have the right endpoint too…

1 Like