loadJSON p5js 401


Hi there

Looking for som help. I am quite new to working with api’s, so please bear with me.

I am trying to make a visualisation of the progress of some specific asana tasks. So what i want is to get the information from these specific tasks.

I am using p5js to load the json files. The file i am loading for testing purposes i am making the request from the exmamples : api/1.0/users/me

When i go this url, i see the .json file. But when i run the following code:

function preload() {
data = loadJSON("https://app.asana.com/api/1.0/users/me", gotData);    

function gotData() {

I get :

GET https://app.asana.com/api/1.0/users/me 401 (Unauthorized)

Uncaught (in promise) Response {type: “cors”, url: “https://app.asana.com/api/1.0/users/me”, redirected: false, status: 401, ok: false, …}

Also i am logged into Asana in the browser.

Thank you, Mikkel



I don’t see why being logged in Asana in the browser can help, but I don’t know p5js. When using the API you need to go through the authentication process, OR maybe you can forge a request and use a token you did receive after logging in in the browser. But in your code I don’t see anything related to authentication, am I missing something?

You can have a look at Organisation level API for all authentication mechanisms.


Hi Bastien,

I worked around this by using the quickstart node.js example from the docs:+1: I think the errors were, as you pointed out, due to not authenticating in any way.

Thought it worked more like one of these open ones: http://api.open-notify.org/, where i could just be logged in to authenticate.

Anyways, thank you!


So does it work now?


Yes got it to work ( using browserify ) :

var asana = require('asana');

var personalAccessToken = "0/00000000000000";

var client = asana.Client.create().useAccessToken(personalAccessToken);

client.tasks.findByTag("0000000000", { limit: 2 }).then(function(collection) {
    var taskDataThisWeek = collection.data;

And then the gotData(taskDataThisWeek) is in my p5.js sketch. So i ended up not needing the loadJSON function. :+1: