How to mock data in Angular applications

Click for: original source

It’s common to use APIs when working with external data sources on some features in Angular. However, you may occasionally work on a feature in parallel without immediate access to the database or API. By Muhammad Amir.

There are several ways to mock the same results. We will discuss three such approaches in this blog:

  • Using json-server
  • Using Postman
  • Mocking data with a simple JSON file

Postman, which used to be a simple browser extension, is now a full-fledged API development toolkit. You can download it separately and install it on your system. To run the mock servers in Postman, we need an account and a workspace. The workspace allows you to easily share the mock server and other APIs with team members.

It’s easy to get started with json-server, and a basic requirement is a simple JSON file with data. There are also JavaScript libraries like MirageJS or axios-mock-adapter for similar purposes. Good read!

[Read More]

Tags angular nodejs app-development web-development frameworks google