[Vuejs]-How to use twilio with dynamic routes in nuxt

0๐Ÿ‘

โœ…

I guess this is more an Express.js related question than a Vue.js question.

You can use the passed sms param from your request, like this:

router.get('/sms/:sms', (req, res, next) => {
  console.log('express reached')
  const accountSid = 'ACCOUNTSIDPLACEHOLDER'
  const authToken = 'AUTHTOKENPLACEHOLDER'

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

  client.messages.create({
    to: req.params.sms,
    from: '+16477993562',
    body: 'This is the ship that made the Kessel Run in 14 parsecs?!'
  })
    .then((message) => console.log(message.sid))
})

Leave a comment