1.1.4 • Published 5 years ago

ng-xhr-promisify v1.1.4

Weekly downloads
3
License
MIT
Repository
github
Last release
5 years ago

ng-xhr-promisify

license release

Wrap XMLHttpRequest in an angular $http-like promise.

Installation

Directly from unpkg:

<script src="https://unpkg.com/ng-xhr-promisify@latest/dist/ng-xhr-promisify.min.js"></script>

With npm:

npm install --save ng-xhr-promisify

With bower:

bower install --save ng-xhr-promisify

Usage

import angular from 'angular';
import ngXhrPromisify from 'ng-xhr-promisify';

const xhr = new XMLHttpRequest();
xhr.open('GET', 'https://api.github.com/repos/tiago/ng-xhr-promisify', true);
xhr.responseType = 'json';
xhr.send();

angular.module('App', [
  ngXhrPromisify
]).run(function (xhrPromisify) {
  xhrPromisify(xhr).then(response => {
    console.log(`${response.data.name}: ${response.data.description}`);
  }).catch(error => {
    console.log(`Error: ${error.status}`);
  }).finally(() => {
    console.log('Bye!');
  });
});
1.1.4

5 years ago

1.1.3

5 years ago

1.1.2

5 years ago

1.1.1

8 years ago

1.1.0

8 years ago

1.0.3

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago