Closed Prasundas99 closed 3 years ago
Try import { Twilio } from "twilio"
?
Thank You the issue has been solved here is the code if someone needs it in future
import twilio from 'twilio';
export const twillosms = async (number, authCode) => {
const accountSid = process.env.TWILIO_ACCOUNT_SID;
const authToken = process.env.TWILIO_AUTH_TOKEN;
const client = new twilio(accountSid, authToken);
await client.messages
.create({
to: `${number}`,
from: '${twillonumber}',
body: ``,
})
.then(message => console.log(message))
.catch((err) => console.log(err))
}
In documentation the code to integrate with node js is as follows:
`var accountSid = process.env.TWILIO_ACCOUNT_SID; // Your Account SID from www.twilio.com/console var authToken = process.env.TWILIO_AUTH_TOKEN; // Your Auth Token from www.twilio.com/console
const client = require('twilio')(accountSid, authToken, { lazyLoading: true });`
but I am using
type:module
in my node js application which means I have to import themSo how should I import the twillio module