mesan-nodejs-auth-crud-api icon indicating copy to clipboard operation
mesan-nodejs-auth-crud-api copied to clipboard

fix: findByIdAndUpdate; callback funtion return object,object

Open codedfinger opened this issue 2 years ago • 2 comments

codedfinger avatar Feb 12 '23 11:02 codedfinger

hotfix: On update of profile image, an error is returned from the mongoose function findByIdAndUpdate.

A detailed explanation can be found here: https://stackoverflow.com/questions/66370059/findoneandupdate-callback-must-be-a-function-got-object-object-nodejs-mon

codedfinger avatar Feb 12 '23 11:02 codedfinger

Also a loop after updating profile image as !req.file checks if there is no file. But using result.url with return the accurate response by checking if image URL was updates on the db.

codedfinger avatar Feb 12 '23 11:02 codedfinger