Reputation: 1662
I am trying to upload image on cloudinary using nodeJs
This is my code
router.post('/imageUpload', upload.single('file'), function(req,res){
User.findById(req.user._id,function(err,user){
if (err) {
console.log(err)
} else {
cloudinary.v2.uploader.upload(req.file.path,
{public_id:user.username},
function(result){
console.log(result)
});
}
})
});
My issue is that ,I am able to upload image on cloudinary file with custom name,but in console it does not loging result(i.e image) object
Instead of that it is returning
undefined
Upvotes: 1
Views: 1176
Reputation: 434
It looks like you're trying to console log the error and since you're having a successful upload, its undefined.
Try the following-
function(error, result) {console.log(error, result);
Upvotes: 3