Reputation: 303
I am trying to make a hello world cloud functions function with firebase, and it is driving me up the wall that I can't make it work. I am trying to use express, and when I send a get request to http://localhost:5000/helloworld I get nothing back. Can someone please take a look at my code and let me know what I'm doing wrong? Thanks! I am serving locally with firebase serve. The console says "emulator started at http://localhost:5000." Here is my code in the index.js file:
const functions = require('firebase-functions');
const admin = require('firebase-admin');
var express = require('express');
admin.initializeApp();
const app = express();
app.get('/helloworld', (req, res) => res.send('Hello World!'));
Thanks!
Upvotes: 0
Views: 347
Reputation: 317808
You never exported a function declaration and attached your Express app to it. I suggest taking another look at the documentation - you need to do something like this:
exports.widgets = functions.https.onRequest(app);
Upvotes: 1