js fetch timeout code example
Example: fetch timeout
function timeoutFetch(promise) {
return new Promise(function (resolve, reject) {
setTimeout(function () {
reject(new Error("timeout"))
}, 5000)
promise.then(resolve, reject)
})
}