-
-
Save DanyF-github/d382f097076ac09636d5721fb5ee307b to your computer and use it in GitHub Desktop.
This file contains 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
// server/src/services/vonage/sms.js | |
... | |
const sendSms = (to, text) => { | |
return new Promise((resolve, reject) => { | |
// get the Vonage client | |
const vonageClient = getVonageClient(); | |
// get the Virtual Phone Number used to send the sms | |
const from = vonageSenderNumber; | |
// Call the sendSms method | |
vonageClient.message.sendSms(from, to, text, (err, responseData) => { | |
if (err) { | |
reject(false); | |
} else { | |
if (responseData.messages[0]['status'] === '0') { | |
console.log('Message sent successfully.'); | |
resolve(true) | |
} else { | |
console.log( | |
`Message failed with error: ${responseData.messages[0]['error-text']}` | |
); | |
reject(false); | |
} | |
} | |
}); | |
}); | |
}; | |
... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment