Amazon Lambda to Firebase

前端 未结 7 1473
甜味超标
甜味超标 2020-11-30 03:42

I get \'Cannot find module \'firebase\' when I try to run this in Lambda (Node.js 4.3)

var Firebase = require(\'firebase\');

Same thing hap

7条回答
  •  爱一瞬间的悲伤
    2020-11-30 04:00

    I solved my problem by using firebase REST api

    var https = require('https');
    
    exports.handler = function(event, context, callback) {
    
        var body = JSON.stringify({
            foo: "bar"
        })
    
       var https = require('https');
    
    var options = {
      host: 'project-XXXXX.firebaseio.com',
      port: 443,
      path: '/.json',
      method: 'POST'
    };
    
    var req = https.request(options, function(res) {
      console.log(res.statusCode);
      res.on('data', function(d) {
        process.stdout.write(d);
      });
    });
    req.end(body);
    
    req.on('error', function(e) {
      console.error(e);
    });
    
        callback(null, "some success message");
    
    }
    

提交回复
热议问题