# Developer console code is not working under JavaScript of browser monitor

**URL:** <https://community.dynatrace.com/t/developer-console-code-is-not-working-under-javascript-of-browser-monitor/38013>\
**Category:** Open Q&A\
**Tags:** browser-monitors, javascript, synthetic-monitoring\
**Created:** [January 16, 2023, 7:55pm UTC](https://community.dynatrace.com/t/developer-console-code-is-not-working-under-javascript-of-browser-monitor/38013 "2023-01-16T19:55:27Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![Julius\_Loman](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/julius_loman/32/51_2.png) [@Julius\_Loman](https://community.dynatrace.com/u/Julius_Loman)\
**Post date:** [January 17, 2023, 8:21am UTC](https://community.dynatrace.com/t/developer-console-code-is-not-working-under-javascript-of-browser-monitor/38013/2 "2023-01-17T08:21:22Z")

</div>

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](https://www.dynatrace.com/support/help/how-to-use-dynatrace/synthetic-monitoring/browser-monitors/browser-clickpath-events#expand--example-2-get-a-random-first-name-last-name-from-an-api-endpoint-and-set-it-during-a-sign-up-process--4).

```markup
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');
});

```

---

_[View the full topic](https://community.dynatrace.com/t/developer-console-code-is-not-working-under-javascript-of-browser-monitor/38013)._
