Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const twilio = require("twilio")(sid, auth_token);
- const sendSMS = asyncHandler(async (req, res) => {
- try {
- const message = await twilio.messages.create({
- from: "+16415524124",
- to: req.body.phoneNumber,
- body: "This is a testing message",
- });
- console.log("Message has been sent:", message.sid);
- res.status(200).json({ success: true, message: "SMS sent successfully" });
- } catch (error) {
- console.error("Error sending SMS:", error);
- res.status(500).json({ success: false, error: "Failed to send SMS" });
- }
- });
Advertisement