I am new to MERN and im developing api for my react application. Im following a tutorial. I have created following code for testing purposes. But the response is not sent and mondoDB collection also not updating. database has connected.
const router = require("express").Router();
const User = require("../models/User");
//Register
router.get('/register', async(req, res) => {
const user = await new User({
username:"Kasun",
email:"banchiyt@gmail.com",
password:"kasun123"
})
await user.save();
res.send("Ok");
});
module.exports = router;
what goes wrong here ? ?