1.0.4 • Published 6 years ago

swapi-promise v1.0.4

Weekly downloads
-
License
MIT
Repository
github
Last release
6 years ago

swapi-promise

Download swapi data asynchronously. swapi-promise do the same using stream.

Requirement

  • Node >= 8.0.0 (swapi-promise 1.x works with node 6.0.0)
  • To be fan of Star Wars

Installation

npm install --save swapi-promise

Usage

To get films list:

const swapi = require('swapi-promise');
const films = await swapi.get(swapi.FILMS);
films.forEach(film => console.log(film.title));

To get planets list:

const swapi = require('swapi-promise');
const planets = await swapi.get(swapi.PLANETS);
planets.forEach(planet => console.log(planet.name));

API

const resources = swapi.get(<resourceName>); // resources is array of required resources

resourceName is mandatory. It's the resource name as defined swapi data Rest API. Rather than typing the name, you can use swapi constants (like shown in above examples):

  • FILMS
  • PEOPLE
  • PLANETS
  • VEHICLES
  • STARSHIPS
  • SPECIES

swapi.get returns full data through a promise.

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago