Skip to main content

How to make a json-server?

 What is a JSON server? 

JSON Server is a simple, lightweight, and mock server that allows you to quickly create a RESTful API with JSON data. It is often used for prototyping, front-end development, or testing purposes.

With JSON Server, you can define a JSON file as a database and expose RESTful endpoints to perform CRUD (Create, Read, Update, Delete) operations on that data. It provides a fully functional HTTP server that responds to various HTTP methods like GET, POST, PUT, and DELETE.

HOW TO MAKE A JSON SERVER IN REACT APP?

STEP1: Create a server folder in the react-js app

STEP2: In the server folder, Initialize the package.json file and install the JSON-server using the following commands.
npm init -y
npm i json-server
STEP 3: Create a db.json file in the server folder and write the data in the db.json file.




STEP 4: Configure the package.json file. Add the following command in the scripts.

  "scripts": {
    "start": "json-server --watch db.json -p 9000"
  },





STEP 5: In The terminal, go to the server folder, and run the npm start command.




Comments

Popular posts from this blog

Youtube Workout Videos to do at home, No equipment Workouts!

Here I am sharing the Youtube Workouts that I am doing these days and You all could do at home and keep yourself fit. Before you follow these workouts daily, I want to tell you, We all have different fitness goals, Some of us want to lose weight, some want that hourglass body shape, and some want to just stay fit! So the intensity and variation of exercise could vary depending on the fitness goal you want to achieve. For beginners, I will recommend doing light exercises first and getting into a habit of doing them daily at a fixed time and then switching to the exercise that brings them closer to their fitness goal. Remember Consistency is the key to reaching your goals! My fitness goal is to stay healthy and have good body posture! Here are some of my favorite youtube workout videos that are helping me achieve my goal. FIX YOUR POSTURE BY EMI WONG HOURGLASS WORKOUT BY DAISY KEECH SUPERMODEL WORKOUT BY EYLEM ABACI If you are a beginner in your fitness journey or want to lose weight ch...