You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Generate the tokens inside the user model.
Create two tokens "access and refresh token"
While creating user don't send the password and access token as a response, through cookie.
Like this:-
const newuser = await User.create({
fullName,
Profile-pic: profilePic?url, //use multer and cloudinary for uploading images
coverImage: coverImage?.url || "",
email,
password,
username: username.toLowerCase()
})
const createdUser = await User.findById(user._id).select(
"-password -refreshToken"
)
if (!createdUser) {
throw new ApiError(500, "Something went wrong while registering the user")
}
return res.status(201).json(
new ApiResponse(200, createdUser, "User registered Successfully")
)
And use "async-await and try catch" while working with database.
Use cookieparser in it.
When I sign up as a new user the browser shows the alert message " Unexpected token '<', "<!DOCTYPE "... is not valid JSON"
The text was updated successfully, but these errors were encountered: