Hello World demo in a browser using "require"?

I’m new to working with Node and APIs in general, but trying to follow along the basic tutorial and documentation (https://developers.asana.com/docs/node-hello-world). The small bit of code/demo is made for the command line, but when using it in a browser it doesn’t work.

It seems to be the var asana = require('asana'); line that’s causing errors. After a little research it looks like I can’t use “require” in a browser. So what should I use instead? And just curious, what exactly is “asana” in that require bracket?

Thanks for any help that can be provided.

I’m getting Uncaught ReferenceError: asana is not defined in the browser console, by the way. And I’m running my local webpage with the http-server node command.

1 Like

I’m have the exact same issue. Have you made any progress? Thanks!

Hi! I figured something out. That line of code: var asana = require('asana'); is actually required. I was able to make the script work just with const client = Asana.Client.create().useAccessToken('myPAtoken');

Now… the next challenge is to get the response to be an object that I can read into an array and format and output to the browser window with javascript. Any help on that would be great.