Skip to content

Instantly share code, notes, and snippets.

@YonathanMeguira
Created June 7, 2018 14:36
Show Gist options
  • Save YonathanMeguira/32438d5ff5ce9290bd2796750926dbca to your computer and use it in GitHub Desktop.
Save YonathanMeguira/32438d5ff5ce9290bd2796750926dbca to your computer and use it in GitHub Desktop.
twilio.js
encodeSpaces(text) {
const find = ' ';
const regex = new RegExp(find, 'g');
return text.replace(regex, '\u00A0');
},
sendSMS(from, message, destination) {
return new Promise((resolve, reject) => {
const targetNumber = destination.substring(1);
client.messages
.create({
body: message,
to: `+${areaCode}${targetNumber}`,
from: from
})
.then(
message => {
resolve(message);
},
err => {
reject(new Error(err.message));
}
);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment