For Login I use POST, below is my code for LOGIN method I used Nodejs with Express and Mongoose
your router.js const express = require("express"); const router = express.Router(); router.post("/login", login); your controller.js export.login = async(req, res) => { //find the user based on email const {email, password} = req.body; try{ const user = awaitUser.findOne({email}); if(user==null) return res.status(400).json({err : "User with email doesnot exists.Please signup"}); } catch(error){ return res.status(500).json({err : error.message}); } //IF EVERYTHING GOES FINE, ASSIGN YOUR TOKEN make sure you have JWT installed const token = jwt.sign({_id: user._id}, YOUR_SECRET_KEY); res.cookie('t'); const {_id, name, email} = user; return res.json({token, user : {_id, email, name}}); }