banner 728x90

Retrieve JavaScript with Timeout

In Mobile Web Development 34 views
banner 728x90

The API for fetching started as a target for criticism due to lack of timeout and cancellation of requests . Although this criticism can be argued as reasonable, you can not deny that the Fetch API has been quite impressive. As we have always done, if a function is missing, we can always fill it.

I recently thought about shimming in a time-out when retrieving and found a good retrieval / timeout script here. I have slightly modified it to prevent the phone calls and and from getting callbacks from performing their duties because I believe that the time-out must be handled by the promise of the shim

const FETCH_TIMEOUT = 5000;
let didTimeOut = false;

new promise (function (solve, refuse) )
.then (function () )
.catch (function (err) );

Wrap this code in a function called fetchWithTimeout where you pass a timeout and retrieve URL / settings would work properly; because people like to use fetch in different ways, I have chosen not to make a generalized function and instead only deliver the basic logic.

Many would argue that the time-out of the server should come, but we all know that the departments of the front-end do not always have control over both sides of an application. If you are looking for a time-out for a time-out for a collection request, you can go here!


  •  How I stopped WordPress Comment Spam

    How I stopped WordPress Comment Spam

    I like to be almost every part of a tech blogger: learning, preaching, cursing, researching. The only part about blogging that I absolutely do not like: dealing with SPAM comments. Over the past two years, my blog has registered 8,000+ SPAM responses per day. PER DAY. Bloating my database …

  •  Create rotating beams with CSS3: Revisited
  •  Introduction of MooTools ScrollSide

    Introduction of MooTools ScrollSide

    This message is a proof of concept post – the functionality still has to be perfected.

    Imagine: you are on a website that uses horizontal scrolling instead of vertical scrolling. It is an artistic site, so you accept that the site scrolls from left to right.

  •  Dress up your selection with FauxSelect

<! –

->

banner 728x90
author
Author: 
    Script & Style Show: Episode 1: Marc Grabanski
    Script & Style Show: Episode 1: Marc Grabanski
    During this second episode of the Script
    AWS AppSync region expansion and new functions for API keys
    AWS AppSync region expansion and new functions for API keys
    AWS AppSync, a managed GraphQL service with
    What is the best time to involve your mobile app users?
    What is the best time to involve your mobile app users?
    When talking to customers about mobile analysis,
    How to make a Twitter bot with Node.js
    How to make a Twitter bot with Node.js
    Twitter bots have been in the news

    Leave a reply "Retrieve JavaScript with Timeout"

    Must read×

    Top