Raathigesh / atmo

:heavy_check_mark: Mock data for your prototypes and demos. Remote deployments to Zeit now.
815 stars 46 forks source link

response dealy [enahcment] #38

Closed pantchox closed 7 years ago

pantchox commented 7 years ago

hi! love the project! small suggestion, maybe for each request can we set a delay, to test client side loaders and such. so for each request you can have "ms" delays, should be a super cool addon.

Thanks!

Raathigesh commented 7 years ago

I'm glad that you find the project useful.

Luckily there is an easy way to achieve this. Atmo allows you to write custom JavaScript where you can access the request and response object of express js (Atmo uses express js under the hood) through req and res variables .

Just select the JavaScript option from the dropdown and use setTimeout() to mimic the delay as shown below and use the res.send() method to send your response.

A bit more detail here.

image

pantchox commented 7 years ago

very interesting! but what if i use json-server? :) thanks for the quick reply!

Raathigesh commented 7 years ago

In that case, you can't :) I will try to add a delay when I could find some time.

Raathigesh commented 7 years ago

https://github.com/Raathigesh/atmo/issues/34