I'm trying to use monday.com's integration feature to send a webhook request to my nextjs application. I receive the data, when I move an element on a board, or update something on an element every time in my handler function which looks like this:
export default function handler(req, res) {
if (req.method === 'POST') {
const challenge = req.body.challenge;
// Respond to the challenge
res.status(200).json(req.body);
} else {
res.status(405).end();
}
}
The challenge was just a parameter from monday to verify the connection, but I'm scared to remove it. I have debugged it several times, and also use ngrok to access the application, since its only on localhost:3000 at the moment.
This whole code is located at: /pages/api/webhook.js
My component is at /app/dashboard/monday/page.tsx and looks as follows:
export default function Page() {
return (
<div className={"h-full w-full"}>
<iframe src="url_to_my_board" width="1700" height="800" ></iframe>
</div>
);
}
My goal is to update this component, or rerender this component, whenever i receive something thru the webhook.
I tried using websockets, as in having a websocket in my handler to then send a message whenever I receive a webhook change. Didn't work.
I tried using context, but I forgot that context only works in react components. So this didn't work either.
There was also a totally desperate and dirty approach of reloading the page every second thru a setInterval in my component, this luckily did also not work.