Async JS with Promise

Is there a way to create a JS script step that can return a Promise and other steps will wait until this promise will be resolved or failed?

Right now I’m using the execute js addon but when I’m using the fetch to return me the data from the request it doesn’t pass the output params

//Get all network API calls and filter 'offers?'
const selectedRequestsArray = {networkRequests}.findLast(response => response.name.includes('/offers?')).name

//Print selectedRequestsArray and offers URL
//console.log('Offers URL: ' + selectedRequestsArray)

//Send Offers URL, extract currency symbol/tla
return fetch(selectedRequestsArray)
  .then(response => response.json())
  .then(data => {console.log(data)
    //Print currency Values
    console.log('currency Symbol is ' + data.currency_symbol)
    console.log('currency TLA is ' + data.currency_tla)
});

Hi @shlomi.b,
The ‘execute JavaScript’ action is an implementation of executeScript by Selenium.
To execute a JavaScript command with promise, you can create an addon which will send an executeAsyncScrupt.
You can read more about it here.