N00b: getting an "undefined" js promise with MDC example code

Can someone tell me why I might be getting an “undefined” promise (the promise state is fulfilled) when I execute the example code from the API documentation? I am assuming it has to do with user rights. I am an admin but it seems like there may be separate controls for what my code can do. Running this script from a server while logged on, in a seperate tab, to MDC.

<HTML>
<head>
  <script src="https://cdn.jsdelivr.net/npm/monday-sdk-js/dist/main.js"></script>

<script>
const monday = window.mondaySdk()
monday.api(`{ users { id, name } }`).then(res => {
  alert(res);
});

</script>
</head>
<body>

</body>
</HTML>

Hello there @Domajo and welcome to the community!

I hope you like it here :muscle:

If I understand correctly, you are not running this in the context of a monday app feature such as a board view or item view. Correct?

Can you please try running this in such a context?

Looking forward to hearing from you!

Cheers,
Matias

1 Like

Thanks for responding Matias, how do I run my own code in the context of a board view? I tried creating a custom app but it seems like I need to be able to run node.js which isn’t really possible on my computer due to corporate security measures.

-Doug

Hello again @Domajo,

You can use your own server to expose your project to the internet and then use a custom URL in your board view feature, or you can have your project in a .zip file and then upload it as a build as explained here

The example we have is using Node.js, but you can use any language for this.

I checked this with the team and you don’t need to have Node in your computer since the SDK is a client-side tool.

I hope that helps!

Cheers,
Matias

1 Like

Ok, so I set up the JavaScript code on my own site and create a custom item view, put in the URL to the code on my site, set the context on the “Board Data” link. It works! It draws in a bunch of data from the item I selected and displays it in the preview page. I set it to V1.0.0 and install it on my board, but when I select an item and go to the tab for my app on the side panel it’s completely blank. Ideas?

-Doug

Hello there @Domajo,

Can you please send a screen recording of this to appsupport@monday.com with the “console” tab of your browser’s inspector open at all times so we can see if any errors appear when you open the view you created?

Looking forward to hearing from you via email!

Cheers,
Matias

1 Like