Related Github Documents
Document Properties
Kbid2939L2
Last Modified22-Apr-2020
Added to KB29-Apr-2020
Public AccessEveryone
StatusOnline
Doc TypeGuidelines, Concepts & Cookbooks
ProductIntershop Progressive Web App

Guide - Intershop Progressive Web App - Mocking REST API Calls

Mocking REST API Calls

Sometimes during development it might be necessary to work with mocked data.
This is especially necessary when developing new features in parallel where backend and frontend are involved.
In the PWA we supply a mocking mechanism so the frontend team can start implementation with mocked data until the backend implementation is finished.

Switching On Mocking

Mocking complete REST responses can be configured in environment.ts.
The property mockServerAPI switches between mocking all calls (true) and only mocking paths that have to be mocked because they do not yet exist in the REST API.
The property mustMockPaths is an array of regular expressions for paths that have to be mocked, regardless if mockServerAPI is enabled or disabled.

Supply Mocked Data

Mocked data is put in the folder assets/mock-data/.
The path is the full path to the endpoint of the service without additional arguments.
The JSON response is put into a file called get.json in the respective folder.

Switching to mocked REST API calls is done by the MockInterceptor which reads all the configuration and acts accordingly.

Disclaimer

The information provided in the Knowledge Base may not be applicable to all systems and situations. Intershop Communications will not be liable to any party for any direct or indirect damages resulting from the use of the Customer Support section of the Intershop Corporate Web site, including, without limitation, any lost profits, business interruption, loss of programs or other data on your information handling system.

Customer Support
Knowledge Base
Product Resources
Support Tickets