Using Fetch Post triggered twice

Hey guys,
I’m trying to send a post a trigger to Zapier via this function that was set in the backend:

export function triggerHook() {     console.log("bla bla bla")   const url = 'https://hooks.zapier.com/hooks/catch/XXXX/XXXX';   return fetch(url, {             method: 'post',             headers: { "Content-Type": "application/json" },             body: JSON.stringify({ fulldate: new Date() })         })         .then(response => {             response.json()               }) }

And on site ready I’m calling this function :
triggerHook()

This thing is that the Zapier api is called twice rather than once.

Any ideas why this could happen?

1 Like

How does your front-end code look like?

@christofferlong200

It does not really matter what functions are called in the front end.
Apparently, you must declare the rendering env for the function.
https://www.wix.com/corvid/reference/draft/wix-window.rendering.html#env



if (wixWindow.rendering.env === "browser") {
        triggerHook();
    }

This resolved this issue.

Great!