Make HTTP request with javascript in camunda 7 execution listeners

Morning everybody.
I’m running camunda inside a docker. I want to use in eventlistner javascript code to make a Get HTTPS request (with fecth or XMLhttprequest).
This is the request I want to make:

fetch('https://jsonplaceholder.typicode.com/todos/1')
      .then(response => response.json())
      .then(json => console.log(json))

But, I’m having an error: ReferenceError: fetch is not defined and ReferenceError: XMLhttprequest is not defined

This is how I did it

Is there any way to do it ? Thanks

Hello @Etse_FIATSI ,

in general, I would recommend to perform a http request as service task or as part of a service task.

Is there a reason why this should be a listener?

Jonathan

Hello @jonathan.lukas, thanks for the response
There isn’t any specific reason. I’m just trying to explore what we can do with js in a listener

Hello @Etse_FIATSI ,

I see, thank you for your explanation. I would recommend to use execution listeners mainly for generic stuff or data mapping.

Jonathan

1 Like

Thanks a lot @jonathan.lukas

1 Like