0

I'm getting this error when I'm trying to deploy a function to firebase. I've used this tutorial. https://firebase.google.com/docs/functions/get-started enter image description here

My package.json is this.

    {
  "name": "functions",
  "description": "Cloud Functions for Firebase",
  "dependencies": {
    "firebase-admin": "^5.4.2",
    "firebase-functions": "^0.7.1"
  },
  "private": true
}

And my index.js is this

const functions = require('firebase-functions');
// The Firebase Admin SDK to access the Firebase Realtime Database. 
const admin = require('firebase-admin');
admin.initializeApp(functions.config().firebase);

// // Create and Deploy Your First Cloud Functions
// // https://firebase.google.com/docs/functions/write-firebase-functions
//
exports.helloWorld = functions.https.onRequest((request, response) => {
 response.send("Hello from Firebase!");
});
// 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((req, res) => {
  // Grab the text parameter.
  const original = req.query.text;
  // Push the new message into the Realtime Database using the Firebase Admin SDK.
  admin.database().ref('/messages').push({original: original}).then(snapshot => {
    // Redirect with 303 SEE OTHER to the URL of the pushed object in the Firebase console.
    res.redirect(303, snapshot.ref);
  });
});

Can you tell me whats wrong in the code? Thanks in advance.

1 Answer 1

1

Your code is fine it is a firebase cloud functions issue.

I already solved in:

issue

fwd: Same issue here. It is a firebase problem.

There is disruption in firebase cloud service since yesterday.

see this image

problem description: https://status.firebase.google.com/incident/Functions/17024

problem solution:

Run the following commands inside the functions repository:

npm install --save-exact [email protected] npm install --save-exact [email protected]

Then try deploying functions again:

firebase deploy --only functions

I hope this helps :)

Sign up to request clarification or add additional context in comments.

1 Comment

Wow it worked. You are life saver. Thanks very much.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.