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

Documentation incorrect for the accounts property #251

Closed
natesilva opened this issue May 19, 2017 · 2 comments
Closed

Documentation incorrect for the accounts property #251

natesilva opened this issue May 19, 2017 · 2 comments

Comments

@natesilva
Copy link

natesilva commented May 19, 2017

(twilio-node version 3.0.0 and Node v7.10.0)

I’m migrating from 2.x and finding that the documentation is wrong. For example, look at the sample code here: https://www.twilio.com/docs/api/rest/account (of course, choose Node.js as the language and 3.x as the SDK version). The code looks like this:

// Download the Node helper library from twilio.com/docs/node/install
// These consts are your accountSid and authToken from https://www.twilio.com/console
const accountSid = '< my account id >';
const authToken = '< my auth token >';

const client = require('twilio')(accountSid, authToken);

client.accounts('< my account id >')
  .fetch()
  .then((account) => console.log(account.dateCreated));

But when I run this I get:

node app.js                                                                  444ms  Fri May 19 09:21:33 2017
/Users/nate/Desktop/tmp/app.js:8
client.accounts('< account id redacted >')
       ^

TypeError: client.accounts is not a function
    at Object.<anonymous> (/Users/nate/Desktop/tmp/app.js:8:8)
    at Module._compile (module.js:571:32)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
    at Module.runMain (module.js:605:10)
    at run (bootstrap_node.js:427:7)
    at startup (bootstrap_node.js:151:9)
    at bootstrap_node.js:542:3

So I’m not sure how to use the accounts property. The docs seem to be wrong?

We use TypeScript so it would really help if we had TypeScript defs (issue #250). That would go a long way towards resolving issues like this as I would be able to see which methods and properties are actually available and work from there.

@jingming
Copy link
Contributor

@natesilva For this special case you will have to use fully qualified path of the resource

client.api.v2010.accounts('AC123')
  .fetch()
  .then((account) => console.log(account.dateCreated));

This is because the domain accounts.twilio.com takes priority on the client.

@natesilva
Copy link
Author

Thank you @jingming, that works. Hopefully the documentation examples can be updated.

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

No branches or pull requests

2 participants