Mind that the root keys of mocks represent HTTP methods, but not provider methods.
The values contain arrays of request objects to match: the algorithm finds the most suitable option and returns its response.
Also, the middleware supports dynamically casting responses:
By default, all data mocks are disabled, but you can enable them just type to a console of a browser:
// Enables mocks for the User provider setEnv('mock', {patterns: ['User']});
// Enables mocks for all providers setEnv('mock', {patterns: ['.*']});
The values of patterns are converted to RegExp objects and applied to provider names (including namespaces).
Config settings are stored within a local browser storage.
core/data/middlewares/attach-mock
This module provides a middleware to attach mock data to a request.
Usage
Mind that the root keys of mocks represent HTTP methods, but not provider methods. The values contain arrays of request objects to match: the algorithm finds the most suitable option and returns its response. Also, the middleware supports dynamically casting responses:
Finally, you can use dynamic importing with mocks:
Enabling data mocks
By default, all data mocks are disabled, but you can enable them just type to a console of a browser:
The values of patterns are converted to RegExp objects and applied to provider names (including namespaces). Config settings are stored within a local browser storage.