Created
October 14, 2020 14:11
-
-
Save umutyerebakmaz/a4668a5850edfec27f6bb7a6acc7e140 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
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