Created
June 7, 2018 14:36
-
-
Save YonathanMeguira/32438d5ff5ce9290bd2796750926dbca to your computer and use it in GitHub Desktop.
twilio.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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