I have a web application in Vue.js 3. I have a component where I render images and provide the option to edit them using the Cloudinary Media Editor. However, whenever I try to achieve it, I encounter an error (TypeError: Cannot read properties of undefined (reading ‘upload’) )
This function receives the event from Cloudinary after the user finishes editing the image:
async handleSaveImageEdit(event) {
// Organize data to pass to the updateImageCloudinary function
const res = await updateImageCloudinary({
path: secure_url,
folder,
transformation,
public_id,
shouldReplace: true,
})
console.log('res:', res)
// Rest of the function
},
event object looks like this:
event = {
assets: [ {
downloadUrl: ‘downloadUrl’,
secureUrl: ‘secureUrl,
url: ‘url,
} ],
transformation: ‘transformation string of the changes the user have done’
}
Then it goes to this function in another file:
import cloudinary from 'cloudinary-core'
const updateImageCloudinary = async ({ path, folder = '', transformation = '', public_id = '', shouldReplace = false }) => {
const cloudinaryCore = new cloudinary.Cloudinary({ cloud_name: 'CLOUD_NAME' })
const options = {
folder: folder,
overwrite: shouldReplace,
raw_transformation: transformation,
resource_type: 'image',
}
if (shouldReplace) {
options.public_id = public_id
}
try {
let result = await cloudinaryCore.uploader.upload(path, options)
return result
} catch (error) {
console.error(error)
throw error
}
}
export default updateImageCloudinary;
As I mentioned before, the error you’re encountering in this function is:
TypeError: Cannot read properties of undefined (reading ‘upload’).
I have already ensured that I receive all the required properties as intended, and the Cloudinary cloud name is also correct.