Setup the Login Function and api route Here we have created a login function which handled the POST request and get username and password as params and then authenticate them if they are correct then return the token if they are correct else return the not found response. map the /api/login route with our function.