I am trying mobile verification with msg91 ..the code run succesfully but msg notsending messagee...it gives the success message ... my code:
router.post('/mobile', async (req, res) =\> {
try {
const sendOtp = new SendOtp(process.env.AUTHKEY);
const mobile = await usermodel.findOne({ mobile: req.body.mobile })
if (!mobile) return res.status(403).send('user not found..')
const otp =`${ Math.floor(1000 + Math.random() * 9000)} `
console.log(otp);
const phonenumber = req.body.mobile
const newPhoneNumber = '+91' + phonenumber
// console.log(newPhoneNumber);
sendOtp.send(newPhoneNumber, otp, function (error, data) {
console.log(data);
console.log(error);
});
res.status(201).send({ status: 'TRUE', message: 'OTP SEND' })
} catch (error) {
res.status(200).send({ status: 'failed', message: 'Unable to Send OTP', error })
console.log(error)
}
})
responce: { message: '326b6774704a343230323437', type: 'success' } null
Use official MSG91 npm package