node-swapi

0.0.3 • Public • Published

node-swapi

npm version

Node wrapper around SWAPI - http://swapi.co/

Requirements

  • node: ">6.0.0"

Installation

npm install node-swapi

Usage

Require a library:

// Require entire library
const SWAPI = require('node-swapi');
 
// or just a particular part, e. g. person
const {person} = require('node-swapi');

Request data from the server

 
 
// get list of people 
SWAPI.people.list()
  .then((data) => {
    data.results.map((item) => {
      console.log(item.name);
    });
  })
  .catch((error) => {
    console.log(error);
  })
 
// get person with id 1
SWAPI.people.get(1)
  .then((data) => {
    console.log(data);
  })
  .catch((error) => {
    console.log(error);
  })
 
// search for Luke Skywalker
SWAPI.people.search('Luke')
  .then((data) => {
    console.log(data);
  })
  .catch((error) => {
    console.log(error);
  })
 

Readme

Keywords

Package Sidebar

Install

npm i node-swapi

Weekly Downloads

0

Version

0.0.3

License

MIT

Last publish

Collaborators

  • apetrosian