We’re implementing the function generateEmployees() to generate a JSON object containing 50 employees. Take a look at the following sample db.json file: module.exports = generateEmployees For objects contained in the JSON structure CRUD entpoints are created automatically. This file contains the data which should be exposed by the REST API. Now let’s create a new JSON file with name db.json. The installation can be done by using the Node.js package manager:īy adding the -g option we make sure that the package is installed globally on your system. JSON Server is available as a NPM package. Furthermore you’ll see how to use another library, Faker.js, to generate fake data for the REST API which is exposed by using JSON server. In the following you’ll lean how to setup JSON server and publish a sample REST API. JSON Server is a simple project that helps you to setup a REST API with CRUD operations very fast. However this takes some time and a much simpler approach can help to speed up front-end development time. Of course you can setup a full backend server, e.g. Ī common task for front-end developers is to simulate a backend REST service to deliver some data in JSON format to the front-end application and make sure everything is working as expected.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |