JS to listen to a webhook

It occurs to me that this might be not overly hard. An XC that picks up a webhook. And returns a value. Feasible? Already been done?

1 Like

Hola Mark!

Do you mean a Yes-Code (YC)? … If so, I think so!.

Maybe a webhook or making an HTTP request to process its reply can be carried out:

const data = await fetch("YOUR_URL")
const json = await data.json();
return json.{Param1}  + " / " +  json.{Param2}  + " / " +  json.{Param3} 

Saludos

1 Like

Sorry if this is a wrong question to ask but does it trigger when data is passed to the webhook or are we sending calls every X seconds to the webhook to ask if it has new data? Is there a chance of new data being missed if we don’t call at the right time? Thank you :grinning_face_with_smiling_eyes:

Hola Thinh

If I understood well your question :laughing:, I’d say the code showed above does:

1- makes an http request
2- waits for its reply
3- retrieves the entire JSON data
4- returns your wished values

In theory, this should be done every time you run the code manually but if you create a way to fire it based on time (using Math and Now), you might have your data updated periodically.

Saludos

1 Like