Cloudinary javascript api ..处理错误

时间:2016-09-27 17:41:38

标签: javascript cloudinary

根据cloudinary js api,上传调用如下:

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

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

回调中没有返回错误。如何捕获错误?

2 个答案:

答案 0 :(得分:1)

您可以使用SDK的v2版本,例如:

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

这里有一个参考: https://github.com/cloudinary/cloudinary_npm/blob/master/test/uploader_spec.coffee#L233-L236

答案 1 :(得分:0)

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