Can not see the Firebase function deployed

后端 未结 15 797
失恋的感觉
失恋的感觉 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:17

    I had exactly the same problem and I solved it by making sure the index.js file containing all my functions was saved on the "functions" folder inside the project folder. I am using vs code so I just clicked on file/save as and selected the correct folder.

    0 讨论(0)
  • 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();
    
    0 讨论(0)
  • 2021-02-02 09:22

    1) Make sure you are exporting the function you are trying to deploy in your index.js file.

    2) Write 'use-strict' at the top of your file (index.js) then use console to deploy your function

    0 讨论(0)
提交回复
热议问题