Quick Start Firebase using Node JS
chowderhead
Posted on April 28, 2019
Photo cred: Fancy crave
Purpose:
This guide will get you up and running with a a very simple Node API firebase backend.
- create a firebase project, click goto console , set it up with all default settings .
- Select default settings for creating new project
- Create a directory where you want to load our firebase project (and navigate to it ):
Sites/firebase_project
Make sure you are inside the new directory of our
firebase_project
If you don't have it installed on your machine, install firebase global package
npm install -g firebase-tools
- if you have never done this before and are not logged in then type:
firebase login
6a. this will open up browser window where it will ask you to login to your google account.
Navigate back to your firebase_project directory and type this:
firebase init
in the command line you will see options , use the arrow keys to select:
Functions: Configure and deploy Cloud Functions
and press spacebar to select it-
now press enter
- when it asks for language, click
Javascript
. - if it asks for ESLINT, press no (unless you want to get bugged often)
- when it asks to install , dependences click yes,
- when it asks for language, click
if you get an error check to make sure your directory has the correct permissions.
if you are still getting an error run firebase init --debug
mode , this will help you see any errors that may appear.
- Navigate to
functions/index.js
and uncomment this :
exports.helloWorld = functions.https.onRequest((request, response) => {
response.send("Hello from Firebase!");
});
- Now from the terminal, inside of the directory run :
firebase deploy
After you deploy, you should get a URL like the one seen below:
Now paste this link that you see in the terminal , into your favourite HTTP request tool, fore example (POSTMAN) and try to hit the URL, and see if you get "Hello from Firebase!"
Congratz!
This is your first node js request endpoint, you can assign a route to it , or add whatever youd like!
Posted on April 28, 2019
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.
Related
November 29, 2024