npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

axiosbluebird

v1.1.11

Published

Axios with Promise (Bluebird) cancelation

Downloads

8

Readme

axiosBluebird

Axios with Promise (Bluebird) cancelation

NODE: v10.15.1

NPM: v6.4.1

For ESM: use @harianto/axioscancelable for example import axiosCancelable from '@harianto/axioscancelable'

How to use - get

const axiosBluebird = require("axiosbluebird")
const Promise = axiosBluebird.Promise
let retrieveDataRequest = Promise.resolve()

const retrieveData = (url, params) => {
  retrieveDataRequest.cancel()
  retrieveDataRequest = axiosBluebird.get(url, params)
  return retrieveDataRequest
    .then(json => json.data)
    .catch(console.error.bind(console, "FAIL - retrieveData:"))
}
retrieveData('http://api.sylo.space/api/valtech/cases', {id: 17})
retrieveData('http://api.sylo.space/api/valtech/cases?id=40', {id: [1,2,3]}) // previous progressing queue will cancel
  .then(console.log.bind(console))

How to use - axios

Parameters as Object in axios documentation

Parameters as String not supported

const axiosBluebird = require("axiosbluebird")
const Promise = axiosBluebird.Promise
let axiosDataRequest = Promise.resolve()

const axiosData = requestConfig => {
  axiosDataRequest.cancel()
  axiosDataRequest = axiosBluebird.axios(requestConfig)
  return axiosDataRequest
    .catch(console.error.bind(console, "FAIL - axiosData:"))
}
// 1st request
axiosData({
  method: "post",
  url: "/user/12345",
  data: {
    firstName: "Fred",
    lastName: "Flintstone"
  }
})

// 2nd request
axiosData({
  method: "get",
  url: "http://bit.ly/2mTM3nY",
  responseType: "stream" })
    .then(response => response.data.pipe(fs.createWriteStream("ada_lovelace.jpg"))
) // previous progressing queue will be canceled

responseType: 'stream' not yet tested

Methods

Promise: Bluebird Promise with Cancelation enabled

axios ( requestConfig: Object ): Request with configuration


delete ( url: String [, params: Object] ): Axios request with DELETE method

get ( url: String [, params: Object] ): Axios request with GET method

head ( url: String [, params: Object] ): Axios request with HEAD method

options ( url: String [, params: Object] ): Axios request with OPTIONS method


post ( url: String, params: Object ): Axios request with POST method

put ( url: String, params: Object ): Axios request with PUT method

patch ( url: String, params: Object ): Axios request with PATCH method

NOTE!

Param properties as array

params: {
  filter: [8, 16, 32]
}

will output:

filter=8&filter=16&filter=32

Idealisticly:

filter=[8,16,32]

But some servers can't accept brackets