-
Hello, Related to - #848 (comment) Help Wanted - Is there any plan to make the queryParam dynamic in the future ? Or what are the other options to implement mock pagination ? tl;dr Followed the following tutorial - https://mockoon.com/tutorials/generate-mock-json-data/ The below excerpt works only for the first time after the server start.
Subsequent calls with different values for total does not work. It's just static. One of the workarounds was to use one of the following API calls. POST /mockoon-admin/data-buckets/purge.
PURGE /mockoon-admin/data-buckets Please let me know how to achieve mock pagination ? Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hi, you are mixing two things: inline body templates and data buckets ("Data" tab). On the other hand, the data buckets are generated at runtime once and for all. Data buckets containing requests helpers (body, queryParam, etc) are only evaluated during the first call referencing them. That lets you create "configuration" endpoints. In both cases, they will never be regenerated again (unless you purge the state, but then it regenerates the bucket completely which is probably not what you want), and there is no pagination whatsoever. Think about it like a small fake "database". If you want automated pagination, I suggest you use the CRUD routes that are linked to a data bucket and offers query parameters like |
Beta Was this translation helpful? Give feedback.
Hi, you are mixing two things: inline body templates and data buckets ("Data" tab).
The inline body template demonstrated in the tutorial you linked to is regenerated during each call. It's mostly stateless and offers no pagination feature. Though, you can achieve this by using rules or templating, which may be a bit cumbersome.
On the other hand, the data buckets are generated at runtime once and for all. Data buckets containing requests helpers (body, queryParam, etc) are only evaluated during the first call referencing them. That lets you create "configuration" endpoints. In both cases, they will never be regenerated again (unless you purge the state, but then it regenerates the bucket…