intro-to-apis-node icon indicating copy to clipboard operation
intro-to-apis-node copied to clipboard

There is a complaint from Twiliio about username being required.

Open kingram6865 opened this issue 5 years ago • 0 comments

/rbd/pnpm-volume/b49f91fe-0cba-47e9-a29d-0c10a9d49189/node_modules/.registry.npmjs.org/twilio/3.39.3/node_modules/twilio/lib/rest/Twilio.js:147
    throw new Error('username is required');
    ^
Error: username is required
    at new Twilio (/rbd/pnpm-volume/b49f91fe-0cba-47e9-a29d-0c10a9d49189/node_modules/.registry.npmjs.org/twilio/3.39.3/node_modules/twilio/lib/rest/Twilio.js:147:11)
    at new initializer (/rbd/pnpm-volume/b49f91fe-0cba-47e9-a29d-0c10a9d49189/node_modules/.registry.npmjs.org/twilio/3.39.3/node_modules/twilio/lib/index.js:9:10)
at Object.<anonymous> (/app/app.js:8:16)
    at Module._compile (internal/modules/cjs/loader.js:701:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
    at Module.load (internal/modules/cjs/loader.js:600:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:539:12)
    at Function.Module._load (internal/modules/cjs/loader.js:531:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:754:12)
    at startup (internal/bootstrap/node.js:283:19)

For the sake of people following along from this point forward, the correct syntax is:

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

This removes the need for instantiating with new twilioClient(), since it's done on the require.

kingram6865 avatar Jan 27 '20 01:01 kingram6865