简体   繁体   中英

How to handle errors with Cloudinary Javascript API?

As per cloudinary JS API, an 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?

You can use the v2 version of the SDK, eg,:

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

cloudinary.uploader.upload(image, function(result) { 
  if (result.error) {
     //error
  }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM