Execute JavaScript in Google Chrome - Empty Results

Hi! :wave:
I'm trying to Execute javascript in Google Chrome. To be more precise: I want to send HTTP request with fetch to a webhook and save returned data to a KM variable.

The thing is: I got an empty results. Code snippet:

(async function() {
const response = await fetch("[webhook_url]", {
"method": "POST",
"headers": {
            "Content-Type": "application/json"
            },
            body: JSON.stringify({
                "url": "test_data"
            })
});
const data = await response.json()
document.kmvar.omfg = data.message;
})();

What am I missing?

Several points:

  1. You can't set a KM variable in a Execute a JavaScript in Browser action.

    • To get data from the script into a KM Variable, return the data as text to the Execute JavaScript action, and choose "save results to variable" for the output option:
    • image
  2. This is a complicated JavaScript question. It is probably best that you post your question on a forum like stackoverflow.com

  3. It may be best to use the bash curl command.