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("/", (req, res) => {
res.send("API is running");
});
app.get("/api/notes", (req, res) => {
res.send(notes);
});
const PORT = process.env.PORT || 5000;
app.listen(PORT, console.log(`server started at ${PORT}`));
Step 5 :
0 Comments