简体   繁体   中英

Meteor wrapAsync not returning value on client

I am trying to use Meteor.wrapAsync to upload a file using Slingshot and then get the upload URL. I've created the function, but image_url ends up being undefined when I run it. The image does successfully upload though.

Getting the image url

var uploadSlingshotFileSync = Meteor.wrapAsync(uploadSlingshotFile);
image_url = uploadSlingshotFileSync(image_file);
console.log(image_url);

Function

uploadSlingshotFile = function(file, callback) {
  var uploader = new Slingshot.Upload("photoUploads");
  uploader.send(file, function (error, uploadURL) {
    callback(null, uploadURL);
  });
};

Is there anything I am missing with the syntax of wrapAsync?

WrapAsync 使函数仅在服务器上看起来是同步的,因为 Fiber 在客户端上不可用。

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