在Lambda Functions AWS中使用Firebase API

维克多

有人可以告诉我该怎么做吗?

这是我到目前为止所拥有的,并且没有将数据添加到我的数据库中

我没有在常规的Web应用程序上使用lambda函数就对此进行了测试,并且可以正常工作

var http = require('http');
var firebase = require('firebase');

exports.handler = (event, context, callback) => {

        var config = {
            apiKey: "AIzaSyCpk23423Iy_akmUniqUJhLt234324YPBE1vD7At8Laj4",
            authDomain: "echoproject-blah.firebaseapp.com",
            databaseURL: "https://echoproject-blah.firebaseio.com",
            storageBucket: "echoproject-blah.appspot.com",
            messagingSenderId: "83962234234322"
        };


   firebase.initializeApp(config);

   firebase.datetbase().ref('/employee/').push({
      med_number: Math.floor(Math.random() * 1000),
      full_name: 'John Smith',
      date_employed: Date.now(),
      email: '[email protected]',
      phone_number: '+123423423',
      profile_picture : 'blah.img'
   }).catch(function(err){
    console.log(err);
   });



    if (event.session.new) {
        onSessionStarted({ requestId: event.request.requestId }, event.session);
    }

    if (event.request.type === 'LaunchRequest') {
        onLaunch(event.request,
            event.session,
            (sessionAttributes, speechletResponse) => {
                callback(null, buildResponse(sessionAttributes, speechletResponse));
            });
    } else if (event.request.type === 'IntentRequest') {
        onIntent(event.request,
            event.session,
            (sessionAttributes, speechletResponse) => {
                callback(null, buildResponse(sessionAttributes, speechletResponse));
            });
    } else if (event.request.type === 'SessionEndedRequest') {
        onSessionEnded(event.request, event.session);
        callback();
    }
   } catch (err) {
    callback(err);
     }



}

我想念什么吗?

我正在尝试将Firebase用于我的Amazon Echo。那会令人烦恼吗?

我的firebase.database无法识别吗?

更新

这些解决方案都不适合我

**解决了**

因此,经过无奈之后,我决定放弃Firebase Node.js SDK,并使用Firebase Endpoint网址

var myJSONObject = {
            med_number: Math.floor(Math.random() * 1000),
            full_name: 'John Bruh',
            date_employed: Date.now(),
            email: '[email protected]',
            phone_number: '+345345',
            profile_picture : '34534534'
        };
request({
    url: "https://echoproject-c78fghfgh6f.firebaseio.com/rest/saving-data/users.json",
    method: "POST",
    json: true,   // <--Very important!!!
    body: myJSONObject
}, function (error, response, body){
    if(error) console.log(error);
    console.log(response);
});
RationalDev喜欢GoFundMonica

具有数据库而非“ datetbase”可能会有所帮助:

firebase.datetbase().ref('/employee/').push({

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章