Hi there,
I always get theis error in http://localhost:5000/api/auth/me.
Got it also in another project but don't know how to fix...
getMe() :
`import { generateTokenAndSetCookie } from "../lib/utils/generateToken.js";
import User from "../models/user.model.js";
import bcrypt from "bcryptjs";
Hi there, I always get theis error in http://localhost:5000/api/auth/me. Got it also in another project but don't know how to fix...
getMe() : `import { generateTokenAndSetCookie } from "../lib/utils/generateToken.js"; import User from "../models/user.model.js"; import bcrypt from "bcryptjs";
export const signup = async (req, res) => { try { const { fullName, username, email, password } = req.body;
} catch (error) { console.log("Error in signup controller", error.message); res.status(500).json({ error: "Internal Server Error" }); } };
export const login = async (req, res) => { try { const { username, password } = req.body; const user = await User.findOne({ username }); const isPasswordCorrect = await bcrypt.compare( password, user?.password || "" );
} catch (error) { console.log("Error in login controller", error.message); res.status(500).json({ error: "Internal Server Error" }); } };
export const logout = async (req, res) => { try { res.cookie("jwt", "", { maxAge: 0 }); res.status(200).json({ message: "Logged out successfully" }); } catch (error) { console.log("Error in logout controller", error.message); res.status(500).json({ error: "Internal Server Error" }); } };
export const getMe = async (req, res) => { try { const user = await User.findById(req.user._id).select("-password"); res.status(200).json(user); } catch (error) { console.log("Error in getMe controller", error.message); res.status(500).json({ error: "Internal Server Error" }); } };
`
Don't even know what I should provide, sorry guys :/ Please help :)