Open toe-lai opened 7 years ago
Check CLI usage, you can add --delay [ms]
, in your case either start with json-server --delay 30000
or create a file called json-server.json
and add that option there.
Hi @toe-lai, Your question is resolved before in this link: https://github.com/typicode/json-server/issues/188
how can i add it in json-server.json
?
Please give us back --delay
option.
Not sure why delay was removed. "use Chrome's Network tab > throttling to delay requests instead of --delay CLI option". What if I used json-server in Next 14 app dir, where I fetch data on the server? How I'm supposed to enable throttling there?
You can do it like this:
const sleep = (ms = 0) => new Promise(resolve => setTimeout(resolve, ms));
await sleep(5000)
await fetch(...)
And if you're using something like axios, probably with an interceptor. There's more control over which request should have a delay or not.
On macOS, you have Network Link Conditioner as well.
i've raised this PR.
meanwhile, I made the same changes locally in the globally installed package and is working fine.
You can check the PR and do the same if you don't wanna wait 🤓
I would like to delay the response time about 30s for testing loading case. Is it possible?