A rule-based API Data Mock plugin built on whistle.
npm i -g whistle
w2 start
w2 install whistle.mockya
Use tools like SwitchyOmega to proxy your website to whistle
[your_api_prefix] mockya://[mockya_collection_id]
# for example
http://mockya.test/api mockya://test
Visit http://localhost:8899/whistle.mockya (replace port with your own one) and install as PWA (recommended)
You can compose your mock data in both JSON5 and JavaScript, along with Mock.js syntax.
Useful when you need to test things like loading state UI.
MockYa has special 'command' syntax to encode specific value in json.
// append '>[command]' to some field
{ "key>[command]": xxx }
// for example
{ "data>encode": { "a": 1 } }
// will return
{ "data": "{\"a\":1}" }
Currently support:
Command | Description |
---|---|
encode | use JSON.stringify to encode field value |