简体   繁体   中英

Firebase Functions response returns null

tried get list of objects from s3(actually from wasabi) but in react always returns null

function code: (using node 8)

exports.fetchWasabi = functions.https.onCall(() => {

  const params = 
  {
        Bucket: 'balde1-webcars',
  };

  s3.listObjectsV2(params, function(err, result) {
        if (!err) {
            console.log(result)
            return result
        } else {
            console.log(err); 
            return err
        }
  });


});

react code:

componentDidMount(){
    var Wasabi = firebase.functions().httpsCallable('fetchWasabi');
    Wasabi().then(function(result) {
        var res = result.data;
        console.log(res)
    }).catch(function(error) {
        console.log(error)
    });
}

when i check the log for the function i can see the result but it never reaches my browser apparently

您没有返回任何东西,因此您应该再添加一个返回值,例如:

return s3.listObjectsV2(params, function(err, result) { ...

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