If you find yourself in a situation where you want to test a specific JSON-response from an API endpoint, but either you can’t get the response you need from your real endpoint or maybe your real endpoint is not ready yet, this is pretty useful.
- Just go to https://designer.mocky.io/
- Press
new mock
button. - Design what kind of response you want to get with various other settings:
I have put this response for a forum question for example:[ { "optionname": "optiona" }, { "optionname": "optionb" } ]
This should return a json array with optionname as the key. - Press
generate ....
button to get the URL:
- You can test the URL in a browser to check if it really returns whatever you want:
- Add the URL to your API connector as usual:
- Initialize as usual:
- Use it wherever you want: