1.0.11 • Published 6 years ago

big-fetch v1.0.11

Weekly downloads
3
License
ISC
Repository
github
Last release
6 years ago

Big Fetch

The big-fetch is a wrapper based on fetch and promise, adding abort and timeout functions. If you like it, please give me your star👼. thx~~~🚀

Features

  • abort(): Set the current promise to rejected
  • timeout: Increase timeout for current request
  • onprogress: progress function

Browser Support

The big-fetch is a wrapper based on fetch and promise, If your browser does not support fetch and promise you need to install whatwg-fetch and promise-polyfill

NPM Install

npm install big-fetch --save-exact

Example

A basic fetch request is really simple to set up. Have a look at the following code:

import bigFetch from 'big-fetch'

bigFetch('http://example.com/movies.json')
  .then(function(response) {
    return response.json()
  })
  .then(function(myJson) {
    console.log(myJson)
  })

Instead of passing a path to the resource you want to request into the fetch() call, you can create a request object using the Request() constructor, and pass that in as a fetch() method argument:

import bigFetch from 'big-fetch'

var myHeaders = new Headers()

var myInit = {
  method: 'GET',
  headers: myHeaders,
  mode: 'cors',
  cache: 'default',
  timeout: 10000 // set 10000ms timeout
}

var request = bigFecth('flowers.jpg', options)

request
  .then(data => {
    console.log(data)
  })
  .catch(error => {
    console.error(error)
  })

// cancel
request.abort()

Issues

☺️Welcome to issues and discuss🌈

1.0.11

6 years ago

1.0.10

6 years ago

1.0.9

6 years ago

1.0.8

6 years ago

1.0.7

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago