Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

fetch-progress

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fetch-progress

Progress of response for fetch API

  • 1.2.0
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

Fetch Progress

Progress of response for fetch API. Get progress report of your response called from fetch like percentage, speed, total, transferred, eta and remaining.

Install

npm i fetch-progress

Usage

import fetchProgress method to your project

import fetchProgress from 'fetch-progress

Now use fetchProgress method on your fetch calls, try to put this before using response. You can

fetch(this.props.src)
    .then(
      fetchProgress({
        // implement onProgress method
        onProgress(progress) {
          console.log({ progress });
          // A possible progress report you will get
          // {
          //    total: 3333,
          //    transferred: 3333,
          //    speed: 3333,
          //    eta: 33,
          //    percentage: 33
          //    remaining: 3333,
          // }
        },
      })
    )

Example

import fetchProgress from '../index';

const self = this;
    fetch(this.props.src)
      .then(
        fetchProgress({
          onProgress(progress) {
            self.setState({ progress });
          },
          onError(err) {
            console.log(err);
          },
        })
      )
      .then(r => r.blob())
      .then(src => {
        this.src = URL.createObjectURL(src);
        this.setState({
          loaded: true,
        });
      });

Demo

Live Demo

Clone this repo and run npm i and npm run dev which will start a server or you can see examples/ folder in this repo.

FAQs

Package last updated on 24 May 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc