I try to use Twilio
in a file .js
, in some labels <script>
I have:
var twilio = require('twilio');
var client = new twilio.RestClient('######', '#####');
client.sms.messages.create({
to:'#######',
from:'#######',
body:'Bienvenido Sr(a): '+$('input[name=nombre]').val()+''
}, function(error, message) {
if (!error) {
console.log('Mensaje enviado');
console.log(message.sid);
console.log('Message sent on:');
console.log(message.dateCreated);
} else {
console.log('Mensaje no enviado');
console.log(error);
}
});
The code works perfectly in a .js
but when I include it somewhere else in a few tags script
obviously, it does not work, it shows me the following error:
ReferenceError: require is not defined ...
Thanks for the attention.