Can not see the Firebase function deployed

后端 未结 15 796
失恋的感觉
失恋的感觉 2021-02-02 08:23

I followed the following steps:

  1. The Firebase CLI (Command Line Interface) requires Node.js and npm, which you can install by following the instructions on https

15条回答
  •  北荒
    北荒 (楼主)
    2021-02-02 09:19

    @Learn2Code I had the exact same issue. Ensure that in your index.js file, you export your function before initializing your app.

    Now, go ahead and run firebase deploy from your project directory.

    For example:

    // Take the text parameter passed to this HTTP endpoint and insert it into the
    // Realtime Database under the path /messages/:pushId/original
    exports.addMessage = functions.https.onRequest(async (req, res) => {
        // Grab the text parameter.
        const original = req.query.text;
        // Push the new message into the Realtime Database using the Firebase Admin SDK.
        const snapshot = await admin.database().ref('/messages').push({original: original});
        // Redirect with 303 SEE OTHER to the URL of the pushed object in the Firebase console.
        res.redirect(303, snapshot.ref.toString());
      });
    
    const admin = require('firebase-admin');
    admin.initializeApp();
    

提交回复
热议问题