reqwest
reqwest copied to clipboard
Document timeout option
This lib supports timeout but not documented anywhere. https://github.com/ded/reqwest/blob/master/src/reqwest.js#L261-L285
Shouldn't the timeout option set XMLHttpRequest.timeout instead of doing a setTimeout() hack? According to MDN:
The XMLHttpRequest.timeout property is an unsigned long representing the number of milliseconds a request can take before automatically being terminated.
One big edge-case to code around:
In Internet Explorer, the timeout property may be set only after calling the open() method and before calling the send() method.
var xhr = new XMLHttpRequest();
xhr.open('GET', '/server', true);
// Timeout must be set after calling open(). Thanks Internet Explorer.
xhr.timeout = 2000; // Time in milliseconds
xhr.onload = function () {
// Request finished. Do processing here.
};
xhr.ontimeout = function (e) {
// XMLHttpRequest timed out. Do something here.
};
xhr.send(null);