Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/franckldx/swapi-promise
https://github.com/franckldx/swapi-promise
Last synced: 22 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/franckldx/swapi-promise
- Owner: franckLdx
- License: mit
- Created: 2017-08-12T18:04:31.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-07-24T21:16:04.000Z (over 6 years ago)
- Last Synced: 2024-10-30T07:07:30.012Z (2 months ago)
- Language: JavaScript
- Size: 53.7 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# swapi-promise
Download [swapi data](https://swapi.co/) asynchronously. [swapi-promise](https://www.npmjs.com/package/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:
```javascript
const swapi = require('swapi-promise');
const films = await swapi.get(swapi.FILMS);
films.forEach(film => console.log(film.title));
```
To get planets list:
```javascript
const swapi = require('swapi-promise');
const planets = await swapi.get(swapi.PLANETS);
planets.forEach(planet => console.log(planet.name));
```## API
```javascript
const resources = swapi.get(); // resources is array of required resources
```
__resourceName__ is mandatory. It's the resource name as defined [swapi data Rest API](https://swapi.co/documentation#root). 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.