# Scripts under discourse api events are failed to run on discourse OOPS page

**URL:** https://meta.discourse.org/t/scripts-under-discourse-api-events-are-failed-to-run-on-discourse-oops-page/191672
**Category:** Support
**Created:** [May 26, 2021, 9:17am UTC](https://meta.discourse.org/t/scripts-under-discourse-api-events-are-failed-to-run-on-discourse-oops-page/191672 "2021-05-26T09:17:14Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![narayanan](https://avatars.discourse-cdn.com/v4/letter/n/ce73a5/32.png) [@narayanan](https://meta.discourse.org/u/narayanan)
#### Post date: [May 26, 2021, 9:17am UTC](https://meta.discourse.org/t/scripts-under-discourse-api-events-are-failed-to-run-on-discourse-oops-page/191672/1 "2021-05-26T09:17:14Z")

</div>

Hi

We had custom javascript written in discourse api events like **onAppEvent** , **decorateWidget** , **onPageChange** ,etc..,. The above api events are working fine on discourse pages. But, those discourse api events are failed to execute the scripts on “ **OOPS** ” page. So we tried to create own discourse api event using the below code to execute,

```plaintext
<script type="text/discourse-plugin" language="javascript">
   if (!('Discourse' in window)) {
        window.Discourse = {};
    }
    if ('Discourse' in window && !('_registerPluginCode' in window.Discourse)) {
        // Make this a noop
       
        window.Discourse._registerPluginCode = function() {};
        // Our scripts
}
</script>

```

When tried this above script, i am getting the error as **“Uncaught TypeError: Cannot read property ‘lookup’ of undefined”**. I don’t know why it’s getting failed on getting themes from discourse.

Refer the below screenshot,

 ![Screenshot (563)](https://global.discourse-cdn.com/meta/original/3X/7/e/7e5cb7b129dbf50a7101159ca16b1e95aabd72a5.png)

**How to overcome the above error to execute custom scripts on OOPS page ?**
