I’m stuck trying to send data to a webhook through Zapier’s JavaScript code action. I need to use the code step because I want to pass dynamic data to the same webhook endpoint.
That callback() approach is outdated for Zapier code steps. Modern Zapier JavaScript actions just need you to return output directly - no callbacks needed. Try this:
Hit this same issue last month. Just ditch the callback completely and make sure you’re returning an object with useful data. Your body syntax was also broken - use proper JSON format with JSON.stringify().
Your fetch request runs but doesn’t return anything - that’s the problem. Zapier code steps need you to return data, not just execute callbacks. Here’s how to fix it: const response = await fetch(‘https://hooks.zapier.com/hooks/catch/123456/abc123/’, { method: ‘POST’, headers: {‘Content-Type’: ‘application/json’}, body: JSON.stringify({name: ‘john’, status: ‘active’}) }); const data = await response.json(); return data; Also, your body format’s wrong - you’re mixing object and string syntax. Use JSON.stringify to format it properly. That return statement’s crucial because Zapier expects output data for the next step.
the main prob is ur not awaiting the fetch & missing the return. zapier code steps need data returned properly or theyll fail. also, that body format is wrong - it should be actual json, not a stringified version. switch to async/await instead of .then chains. its much cleaner.