0

When ever I use the command 'firebase serve', the localhost address that is provided to me does not actually work.

The error that I am getting says that some credentials could not be loaded. According to other overflow answers, I am defining functions, admin and initializing the app correctly.

const functions = require('firebase-functions');
// importing the admin
const admin = require('firebase-admin');

// initializing the application in order to use app
admin.initializeApp();

// setting up express 
const express = require('express')
const app = express();
app.post('/scream' ,(req, res) =>{

   const newScream ={
    //    second body is a property of the request
       body: req.body.body,
       userHandle: req.body.userHandle,
      createdAt: admin.firestore.Timestamp.fromDate(new Date()) 
   }

   admin.firestore().collection('screams').add(newScream)
   .then(doc => {
    //    string literal for response stating successful addition of the newScream object
       res.json({message: `doucument${doc.id} created successfully`})
   })
   .catch((err)=>{
       res.status(500).json({error: 'Something went wrong'})
       console.log(err)
   })
})
exports.api= functions.https.onRequest(app)

I am expecting to run 'firebase serve', get the localhost address, and then use a post method with a json body to test the route in Postman. I am expecting a successful route however credentials do not load so the attempt ends before I can post anything to the database.

J. Murray
  • 1,460
  • 11
  • 19
  • Please post the details of your problem (including a very specific error message) to an issue on the firebase-tools github. https://github.com/firebase/firebase-tools – Doug Stevenson Oct 14 '19 at 22:53
  • @DougStevenson I should post this as a bug or request, even though I am just not sure why I am getting this issue? I don't know which of the two I should do? – Camerone Stoney Oct 14 '19 at 23:36
  • 1
    It sounds like a bug, and it also sounds like possibly a duplicate, so be sure to search first to see what already exists. – Doug Stevenson Oct 14 '19 at 23:38

0 Answers0