How to send otp to login and to verify phone number using NodeJS

I am working on a app and creating the user registration and login. I am providing the option of login through phone or normal login and the user can add and verify his number after logging in. So If a user wants to login through phone he should enter his phone and then an otp will be sent to his number to login. And if a user loggedin using his username and password and wants to add his phone number then a otp will be sent to verify his number. I don't have any knowledge in this so I haven't tried anything as of now and need help. I am using MongoDB in my database.

1 answer