Skip to content

Instantly share code, notes, and snippets.

@umutyerebakmaz
Created October 14, 2020 14:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save umutyerebakmaz/a4668a5850edfec27f6bb7a6acc7e140 to your computer and use it in GitHub Desktop.
Save umutyerebakmaz/a4668a5850edfec27f6bb7a6acc7e140 to your computer and use it in GitHub Desktop.
import Nexmo from 'nexmo';
export function sendSms(sender: string, recepient: string, message: string): void {
const nexmo = new Nexmo({
apiKey: '****',
apiSecret: '*****',
});
// const sender = 'Vonage APIs';
// const recepient = '****';
// const message = 'Hello from Vonage SMS API';
const opts = {};
return nexmo.message.sendSms(sender, recepient, message, opts, (err, data) => {
if (err) {
console.log(err);
} else {
if (data.messages[0]['status'] === "0") {
console.log("Message sent successfully.");
} else {
console.log(`Message failed with error: ${data.messages[0]['error-text']}`);
}
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment