Search
 
SCRIPT & CODE EXAMPLE
 

CSS

Timeout for a fetch

async function fetchWithTimeout(resource, options = {}) {
  const { timeout = 8000 } = options;
  
  const controller = new AbortController();
  const id = setTimeout(() => controller.abort(), timeout);
  const response = await fetch(resource, {
    ...options,
    signal: controller.signal  
  });
  clearTimeout(id);
  return response;
}
Comment

fetch timeout

function timeoutFetch(promise) {
    return new Promise(function (resolve, reject) {
        setTimeout(function () {
            reject(new Error("timeout"))
        }, 5000)
        promise.then(resolve, reject)
    })
}
Comment

PREVIOUS NEXT
Code Example
Css :: css move animation 
Css :: css attribute selector 
Css :: css animation display none 
Css :: glass css 
Css :: Align vertically and horizontally 
Css :: css style placeholder 
Css :: liste decoration css 
Css :: css center table on page 
Css :: html css make p div into two lines 
Css :: wp query using the_post 
Css :: button type submit css selector 
Css :: space-evenly vs space-around 
Css :: html table scrollable body fixed header 
Css :: line middle text css 
Css :: position absolute 
Css :: css vendor prefixes 
Css :: css inverted border radius 
Css :: overlay color on image css 
Css :: sticky footer not working bootstrap 
Css :: media-queries 
Css :: horizontal scroll css images 
Css :: selecting last child css 
Css :: css nth-child 
Css :: css cut lines 
Css :: css gradient background 
Css :: linux copy directory permissions to another directory 
Css :: border shorthand css 
Css :: css list in line 
Css :: rgba blue 
Css :: css background gradient 
ADD CONTENT
Topic
Content
Source link
Name
9+2 =