Skip to the content.

What is it?

It’s basically a tool to help test offline detection and timeouts. I needed this for a Pen playing with offline detection.

It is licensed under MIT.

Specification

https://timeout-as-a-service.herokuapp.com/<wait_time>/<status_code>

Simply call the API above with your choice of GET, PUT, POST or DELETE, with:

After waiting for the prescribed amount of time, it will return a JSON object.

For example, to return a 200 OK after 1 second (or 1000ms), simply call:

https://timeout-as-a-service.herokuapp.com/1000/200

After a second, you will get back this:

{
    "waitTime": 1000,
    "status": 200
}

Code Example

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();

Contributing

If you want a feature or have a question:

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.