如何修复Node.js中的“标题已发送”错误

时间:2019-07-23 16:24:20

标签: javascript node.js

const functions = require('firebase-functions');

const admin = require('firebase-admin');
admin.initializeApp();

const DialogflowApp = require('actions-on-google').DialogflowApp;

exports.receiveAssistantRequests = functions.https.onRequest((request, response) => {

    const app = new DialogflowApp({request: request, response: response});

    function handlerRequest(app) {

        const device = app.getArgument('devices');
        const status = app.getArgument('status');

        return admin.database().ref(`/automation/${device}/value`).set(status)
            .then(snapshot => {
                app.ask(`Ok, switching ${device} ${status}. Do you want to control anything else?`);
            });

    }
    app.handleRequest(handlerRequest);
});

0 个答案:

没有答案