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