runtimeZero runtimeZero - 29 days ago 6
Javascript Question

Cloudinary javascript api.. handling errors

As per cloudinary js api, upload call looks like:

https://www.npmjs.com/package/cloudinary

cloudinary.uploader.upload(fileLocation, function(result) {
..something
});


There is no error returned in the callback. How do I capture the error ?

Answer

You can use the v2 version of the SDK, e.g.,:

cloudinary.v2.uploader.upload("sample.jpg", 
    function(error, result) {console.log(result); });

Here's a reference: https://github.com/cloudinary/cloudinary_npm/blob/master/test/uploader_spec.coffee#L233-L236