Lesson 6 - Linking Backend to Frontend | Learning MERN Stack

 Step 1 - Go to mern-stack/frontend 

Step 2 : Type "Ctrl + ` and your terminal will be opened

Step 3 : Install axios - npm i axios

Step 4 :  

Create API in index.js file : 

const express = require("express");
const dotenv = require("dotenv");
const app = express();
dotenv.config();

app.get("/", (reqres=> {
  res.send("API is running");
});

app.get("/api/notes", (reqres=> {
  res.send(notes);
});

const PORT = process.env.PORT || 5000;
app.listen(PORTconsole.log(`server started at ${PORT}`));


Step 5 : 

0 Comments