http-francis

description of http-francis

Usage no npm install needed!

<script type="module">
  import httpFrancis from 'https://cdn.skypack.dev/http-francis';
</script>

README

http-francis

Build Status Coverage Status npm version Bower version GitHub version

an http class to make requests over the net with retry and interval between them

Usage

var Francis = require('http-francis');
var francis = new Francis.Http({
    method:"GET", // JSONP, POST, DELETE, PUT
    url:"https://httpbin.org/get"
});

Installation

NPM

npm install --save http-francis

You can found the library ready for production on node_modules/http-francis/dist/dist.js

Bower

bower install --save http-francis

You can found the library ready for production on bower_components/http-francis/dist/dist.js

Example

var Francis = require('http-francis');
var francis = new Francis.Http({
    method:"GET", // JSONP, POST, DELETE, PUT
    url:"https://httpbin.org/get"
});

francis.promise.then((response) => { 
    response // [data, xhr.status, xhr]
 })

Retrieve an image as base64

var Francis = require('http-francis');
var francis = new Francis.Http({
    method: "GET",
    url: "https://someimageurl/image.png",
    responseType: "blob",
    mimeType: "image/png",
    onProgress:(percentage)=>{ 
        // there must be Content-Length header in the response to get the right percentage
        // otherwise percentage is a NaN
    }
});

francis.promise.then((response) => { 
    var imgTag = document.createElement("img");
    imgTag.src = response[0];
    document.body.appendChild(imgTag);
    
 })

Documentation

To read documentation, go to:

http://d-mobilelab.github.io/http-francis/0.1.2

Replace 0.1.2 with the version of the documentation you want to read.