Developer console code is not working under JavaScript of browser monitor

Looks like the editor does not know the await keyword at all and . Using your snippet above gives me the following error:

Exception was thrown by the JavaScript code: await is only valid in async functions and the top level bodies of modules

which probably pretty explains why it is also not working even if you save the JavaScript synthetic event.

If you need to call an external API in your JavaScript event, you can do it this way.

api.startAsyncSyntheticEvent();
fetch('https://randomuser.me/api/').then((resp) => resp.json()).then(function(data) {
    document.getElementById('firstName').value = data.results[0].name.first;
    document.getElementById('lastName').value = data.results[0].name.lastname;
    api.finish();
}).catch(function(error) {
    api.fail('Fetch request to randomuser.me failed');
});