# Unhandled Promise rejection: Communicator is not defined

**URL:** <https://forum.techsoft3d.com/t/unhandled-promise-rejection-communicator-is-not-defined/310>\
**Category:** HOOPS Visualize Web\
**Created:** [April 27, 2021, 3:09pm UTC](https://forum.techsoft3d.com/t/unhandled-promise-rejection-communicator-is-not-defined/310 "2021-04-27T15:09:48Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![diego.bazan](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.techsoft3d.com/diego.bazan/32/68_2.png) [@diego.bazan](https://forum.techsoft3d.com/u/diego.bazan)\
**Post date:** [April 27, 2021, 3:09pm UTC](https://forum.techsoft3d.com/t/unhandled-promise-rejection-communicator-is-not-defined/310/1 "2021-04-27T15:09:48Z")

</div>

Hello!

I have set up an [ASP.NET](http://ASP.NET) Core with angular project. I have been trying to run this code from the tutorial ([Bitbucket](https://bitbucket.org/techsoft3d/ts-webviewer-basic-app/src/master/)):  
`//! [create\_viewer]  
var viewer: Communicator.WebViewer = null;

async function createViewer() {  
viewer = new Communicator.WebViewer({  
model: “microengine”,  
containerId: “viewer”,  
endpointUri: “ws://localhost:11180”, });  
viewer.start(); }

$(() =\>{  
createViewer();  
});  
//! [create\_viewer] `

It builds fine, I can hover over Communicator and the intellisense provides a definition, but when I open my page in google chrome, I get the following error:

 ![CommunicatorError](https://us1.discourse-cdn.com/flex020/uploads/techsoft3d/original/1X/224d6ebf1f54171d56388214bc344abec73f6bf2.png)

---

<div class="post-metadata">

**Author:** ![diego.bazan](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.techsoft3d.com/diego.bazan/32/68_2.png) [@diego.bazan](https://forum.techsoft3d.com/u/diego.bazan)\
**Post date:** [April 27, 2021, 3:33pm UTC](https://forum.techsoft3d.com/t/unhandled-promise-rejection-communicator-is-not-defined/310/2 "2021-04-27T15:33:28Z")

</div>

So I added the catch () and real error seems to be:  
 ![ComError2](https://us1.discourse-cdn.com/flex020/uploads/techsoft3d/original/1X/f9fff0cbf37fba3aba468d4490c56b0c57c77edf.png)

Any clue what might be happening here?

---

<div class="post-metadata">

**Author:** ![cpillion](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.techsoft3d.com/cpillion/32/70_2.png) [@cpillion](https://forum.techsoft3d.com/u/cpillion)\
**Post date:** [April 27, 2021, 9:27pm UTC](https://forum.techsoft3d.com/t/unhandled-promise-rejection-communicator-is-not-defined/310/3 "2021-04-27T21:27:30Z")

</div>

Hello,

Thanks for reaching out and thanks for your patience while we looked into this. Would you be able to tell me how you are providing the hoops\_web\_viewer.js source file in your application? Are you using a tag in your html to bring it in? Or are you trying to use ES6 ‘import’ commands?

I am wondering if the Communicator class is just out of scope in your application. Out of curiosity, and if you are including the library in a script tag, if you try accessing the Communicator class in the context of the global window, is Communicator defined?

```
async function createViewer() {
viewer = new window.Communicator.WebViewer({
model: “microengine”,
containerId: “viewer”,
endpointUri: “ws://localhost:11180”, });
viewer.start(); }
```

---

<div class="post-metadata">

**Author:** ![diego.bazan](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.techsoft3d.com/diego.bazan/32/68_2.png) [@diego.bazan](https://forum.techsoft3d.com/u/diego.bazan)\
**Post date:** [April 28, 2021, 12:56pm UTC](https://forum.techsoft3d.com/t/unhandled-promise-rejection-communicator-is-not-defined/310/4 "2021-04-28T12:56:51Z")

</div>

Thanks for getting back to me!

I’ve tried a few things in order to provide hoops\_web\_viewer.js. I have the way the tutorial says to do it:  
 ![hwvjs](https://us1.discourse-cdn.com/flex020/uploads/techsoft3d/original/1X/0a2b98f2bd3c680e9bbffbbb01e215bb9c3da9f9.png)  
Where my assets folder looks like this:  
picture 2

I also supplemented it in my html file (just to try stuff lol):  
picture 3

Accessing the Communicator class in the context of the global window gives me the following compile error:  
picture 4

Which is weird because visual studio makes it look like its ok:  
picture 5

Thanks for the help!

---

<div class="post-metadata">

**Author:** ![diego.bazan](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.techsoft3d.com/diego.bazan/32/68_2.png) [@diego.bazan](https://forum.techsoft3d.com/u/diego.bazan)\
**Post date:** [April 28, 2021, 12:57pm UTC](https://forum.techsoft3d.com/t/unhandled-promise-rejection-communicator-is-not-defined/310/5 "2021-04-28T12:57:29Z")

</div>

picture 2  
 ![assetsfolder](https://us1.discourse-cdn.com/flex020/uploads/techsoft3d/original/1X/0654adf8d30bad8d6c928461882b203d7e29fc64.png)

---

<div class="post-metadata">

**Author:** ![diego.bazan](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.techsoft3d.com/diego.bazan/32/68_2.png) [@diego.bazan](https://forum.techsoft3d.com/u/diego.bazan)\
**Post date:** [April 28, 2021, 12:59pm UTC](https://forum.techsoft3d.com/t/unhandled-promise-rejection-communicator-is-not-defined/310/6 "2021-04-28T12:59:13Z")

</div>

picture 3:  
 ![html](https://us1.discourse-cdn.com/flex020/uploads/techsoft3d/original/1X/b820898994168d93d02b596983ae154b5f34cb78.png)

---

<div class="post-metadata">

**Author:** ![diego.bazan](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.techsoft3d.com/diego.bazan/32/68_2.png) [@diego.bazan](https://forum.techsoft3d.com/u/diego.bazan)\
**Post date:** [April 28, 2021, 1:03pm UTC](https://forum.techsoft3d.com/t/unhandled-promise-rejection-communicator-is-not-defined/310/7 "2021-04-28T13:03:50Z")

</div>

picture 4:

 ![window](https://us1.discourse-cdn.com/flex020/uploads/techsoft3d/original/1X/0853308c660a76f0669a32eba2331821de38205b.png)

---

<div class="post-metadata">

**Author:** ![diego.bazan](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.techsoft3d.com/diego.bazan/32/68_2.png) [@diego.bazan](https://forum.techsoft3d.com/u/diego.bazan)\
**Post date:** [April 28, 2021, 1:04pm UTC](https://forum.techsoft3d.com/t/unhandled-promise-rejection-communicator-is-not-defined/310/8 "2021-04-28T13:04:48Z")

</div>

picture 5:

 ![windowcom](https://us1.discourse-cdn.com/flex020/uploads/techsoft3d/original/1X/1f9ae2928a6bc5329c6dc3e72ce2c2f15159e26d.png)

(sorry for the onslaught of replies, forum only lets me post one picture per message!)

---

<div class="post-metadata">

**Author:** ![diego.bazan](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.techsoft3d.com/diego.bazan/32/68_2.png) [@diego.bazan](https://forum.techsoft3d.com/u/diego.bazan)\
**Post date:** [April 28, 2021, 4:32pm UTC](https://forum.techsoft3d.com/t/unhandled-promise-rejection-communicator-is-not-defined/310/9 "2021-04-28T16:32:03Z")

</div>

Figured it out! A silly mistake by me, i was pointing to the wrong folder when trying to get hoops\_web\_viewer.js… Sorry for all the trouble and thanks for all the help!

---

<div class="post-metadata">

**Author:** ![Jonathan](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.techsoft3d.com/jonathan/32/44_2.png) [@Jonathan](https://forum.techsoft3d.com/u/Jonathan)\
**Post date:** [April 28, 2021, 8:07pm UTC](https://forum.techsoft3d.com/t/unhandled-promise-rejection-communicator-is-not-defined/310/10 "2021-04-28T20:07:19Z")

</div>

A common mistake. Glad you got it sorted.

Just a note, we’ve created a sample integration between the HOOPS Web Platform and angular. It is now available on GitHub here:

> **[techsoft3d/hwp-demo-angular](https://github.com/techsoft3d/hwp-demo-angular)**
>
> A basic demo showing how to implement Hoops Web Platform into an Angular project.

---

<div class="post-metadata">

**Author:** ![diego.bazan](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.techsoft3d.com/diego.bazan/32/68_2.png) [@diego.bazan](https://forum.techsoft3d.com/u/diego.bazan)\
**Post date:** [April 29, 2021, 2:13pm UTC](https://forum.techsoft3d.com/t/unhandled-promise-rejection-communicator-is-not-defined/310/11 "2021-04-29T14:13:23Z")

</div>

Thats awesome and it will be super useful to me! Thank you!
