I think don't use 'uploader'
there's error
TypeError: Cannot read properties of undefined (reading 'uploader')
but i coding right here
const cloudinary = require("cloudinary").v2;
app.post('/api/product/image/delete', (req, res) => {
let deleteImg = req.body
deleteImg.forEach((item) => {
cloudinary.v2.uploader.destroy(item.public_id);
})
})
i think it's problem right this. cloudinary.v2.uploader.destroy(item.public_id);
What's the problem?
1
-
Hi Choyen,
When the v2 is already declared during object instantiation, it is no longer needed when calling the methods (as described in this documentation: https://cloudinary.com/documentation/node_integration#installation_and_setup). For example:
var cloudinary = require('cloudinary').v2;
cloudinary.uploader.upload("my_image.jpg", function(error, result) {console.log(result, error)});Hope this helps.
3
Post is closed for comments.
Comments
1 comment