Setting up json-server to serve json data for Angular app

The json-server is a simple server to serve json data for playing with Angular app in development. If you are learning AngularJS and want to play with json data you can use this json-server to serve static content for you!!

Installing json-server:

npm install json-server -g


Setting up a folder to serve:

Create a folder at any convenient place.

mkdir foldername

Move to that folder

cd foldername

Place your .json file in this folder eg: db.json To serve your content

$json-server --watch db.json

\{^_^}/ hi!

Loading db.json



Type s + enter at any time to create a snapshot of the database

Now open your favourite browser and navigate to the said links you can see your json being served!!

If you want to serve images or any other static content then you need to put those in public folder.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s