Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In get-message route #7

Open
DevSagarKumarJha opened this issue Apr 30, 2024 · 2 comments
Open

In get-message route #7

DevSagarKumarJha opened this issue Apr 30, 2024 · 2 comments

Comments

@DevSagarKumarJha
Copy link

    if (!user || user.length === 0) {
        return Response.json(
            { success: false, message: 'User not found', },
            { status: 404 }
        );
    }
    here checking length of message is after aggregation pipeline 
    is creating error user-not found for new user
@DevSagarKumarJha
Copy link
Author

As we are getting message array from the db using pipeline instead of User not found we can give message: message not found error

@Aftershock007
Copy link

if (!userMessages || userMessages.length === 0) { return Response.json( { success: true, message: "No Messages" }, { status: 200 } ) }
this worked for me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants