hiteshchoudhary / ama-app

https://truefeedback.in
316 stars 63 forks source link

In get-message route #7

Open DevSagarKumarJha opened 6 months ago

DevSagarKumarJha commented 6 months ago
    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 commented 6 months ago

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 commented 6 months ago

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