I am trying to retrieve all projects in express, and this is my code.
var Asana = require(‘asana’);
var client = Asana.Client.create({
clientId: ,
clientSecret:,
redirectUri: ‘http://localhost:8000’
}).useAccessToken(‘*****’);
console.log(client.projects);
When I print client.projects, it only shows
Projects {
dispatcher:
Dispatcher {
authenticator: OauthAuthenticator { credentials: [Object], flow: null, app: undefined },
asanaBaseUrl: ‘https://app.asana.com/’,
retryOnRateLimit: false,
handleUnauthorized: [Function],
_cachedVersionInfo: null,
requestTimeout: null } }
So how can i retrieve all the projects? Thanks.
If possible, please show me any related information, thanks a lot!
Hi Bastien, thanks for your reply. Do you mean this?
when i try this code: client.users.me().then(function (user) {
console.log(user);
})
I can get the user id, email, name, photo, and workspaces after print the “user”.
And I need to retrieve all the projects from this workspace. What kinds of syntax I can use? And where can I check those syntax from documentation? I have read the github code(GitHub - Asana/node-asana: Official node.js and browser JS client for the Asana API v1) but I didn’t see it.
Thanks.
@Jeff_Schneider Hi Jeff, I have one more question about this.
I am trying to retrieve one specific project, after read the documentation, I try this code:
client.projects.findById({ “project”: 12345678}).then(function (response) {
console.log(response);
})
but it doesn’t work.
In the documentation,
Projects.prototype.findById = function(
project,
params,
dispatchOptions
) {
var path = util.format(‘/projects/%s’, project);
return this.dispatchGet(path, params, dispatchOptions);
};
How can i make the correct format of the params? Thanks a lot.
Firstly thanks for the answer you provided, I had the same problem as Jiahao and now I’m getting all projects correctly. However I was wondering why when using:
I am getting both “collection data” with the list of projects and “response data” which is composed of a repetition of "{Object}, {Object}, … ? Is it better to always use “collection” instead of “response” ? Why am I getting this list ?