I "needed" this for a Pen playing with offline detection. It is, of course, a silly idea. Parafoxically it has found one or two quasi-legitimate uses.
It's now archived.
For fast and simple deployment on Heroku, you can use the button below.
Sports a handeh-dandeh two-parameter API.
Call the API with your choice of GET
, PUT
, POST
, DELETE
with
- a timeout in miliseconds, and
- a valid status code you want returned
https://timeout-as-a-service.herokuapp.com/<timeout-in_miliseconds>/<status_code>
You'll get back a JSON object once the request completes:
{
"waitTime": 1000,
"status": 200
}
https://timeout-as-a-service.herokuapp.com/5000/418
CORS allows Origin '*'
, so you should be able to use this from anywhere.
- No, it won't reflect a response elsewhere. Obviously. That would be insane.
- By default wait times are limited to 90 seconds unless you have specified a different maximum wait time with the
MAX_WAIT_TIME
environment variable.
const timeout = 2000,
const status = 200;
const url = `https://timeout-as-a-service.herokuapp.com/${timeout}/${status}`;
request = new XMLHttpRequest();
request.addEventListener("timeout", () => console.log("Timed out!"));
request.addEventListener("load", data => console.dir(data));
// This will cause a timeout:
request.timeout = timeout - 1000;
request.open("GET", url);
request.send();
If you want a feature or have a question:
- Read the closed issues, then
- Read the open issues
If unsatisfied by what you find, please file an issue.
If you already have a solution in mind, you can then fork, and submit a pull request, but please file an issue first.
MIT