Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Property 'ApiClient' does not exist on type 'typeof asana'. Did you mean 'Client'?ts(2551) #296

Open
Strooss opened this issue Apr 23, 2024 · 2 comments

Comments

@Strooss
Copy link

Strooss commented Apr 23, 2024

Types don't really match the code

@jv-asana
Copy link
Contributor

jv-asana commented Apr 26, 2024

Hi @Strooss which version of the node-asana are you using? In our v1.X.X (EX:v1.0.5) you would use asana.Client while in v3.X.X [EX: v3.0.6] it's Asana.ApiClient

node-asana v1.0.5:

const asana = require('asana');

const client = asana.Client.create().useAccessToken("<YOUR_ASANA_PERSONAL_ACCESS_TOKEN>");

client.users.getUser("me").then((result) => {
    console.log(result);
});
v1_sample_code

node-asana v3.0.6:

const Asana = require('asana');

let client = Asana.ApiClient.instance;
let token = client.authentications['token'];
token.accessToken = "<YOUR_ASANA_PERSONAL_ACCESS_TOKEN>";

let usersApiInstance = new Asana.UsersApi();
let user_gid = "me"; // String | A string identifying a user. This can either be the string \"me\", an email, or the gid of a user.
let opts = {};

usersApiInstance.getUser(user_gid, opts).then((result) => {
    console.log('API called successfully. Returned data: ' + JSON.stringify(result.data, null, 2));
}, (error) => {
    console.error(error.response.body);
});
v3_sample_code

@oev-chrisbennett
Copy link

oev-chrisbennett commented May 24, 2024

@Strooss the @types/asana package matches the types in the previous version of asana.

npm remove @types/node
rm -rf node_modules
npm install

then restart your editor, and the type issues should disappear. Sadly you'll have no types 😞

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants