Create a REST API Using Angular and JSON Server
Create a full REST API in Angular for prototyping and mocking back-end services in no time
In this guide, we will create a REST API using Angular and JSON Server. As Front-end developers we are often required to simulate a back-end REST service that returns JSON data.
You could, of course, create a fully-fledged back-end server. However, we will save both pain and time by using a much simpler approach. And utilizing tools you are already familiar with.
The code for this project is available on this GitHub repository.
Creating the Project
Without further ado, Let’s begin by creating an Angular project in your projects folder using Angular CLI. Run the command:
$ ng new json-server-api
Just press Enter to the subsequent command prompts, in order to use the default configurations.
Installing JSON Server
To get JSON responses from our REST API, we will need a web server. For this guide we make use of json-server. A freely available npm package.
Install JSON Server globally using the command: