DEV Community

Discussion on: Image Upload to Cloudinary with Nodejs and Dotenv

Collapse
 
adybecky profile image
_beckyady

Hi... what if i want to have this part of the code in a separate file

// upload image here
cloudinary.uploader.upload(data.image)
.then((result) => {
response.status(200).send({
message: "success",
result,
});
}).catch((error) => {
response.status(500).send({
message: "failure",
error,
});
});

Collapse
 
ebereplenty profile image
NJOKU SAMSON EBERE

Hey Becky, that is absolutely fine and well recommended especially for big projects.

I did just that in this article

I hope you find the answer there. If you have more questions, I am still available 😊