Socket
Book a DemoInstallSign in
Socket

apist

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

apist

Simple REST API client

latest
Source
npmnpm
Version
0.1.1
Version published
Maintainers
1
Created
Source

apist

Build Status Coverage Status Dependency Status

Simple REST API client

THIS PACKAGE IS NO LONGER MAINTAINED

Install

$ npm install --save apist

Usage

import Apist from 'apist';

const users = new Apist('users');

users.fetch(10, { query: 'query' }).then(data => console.log(data.firstName));
//=> GET /users/10?query=query

Within the used fetch. You can add polyfill to your project.

Configure to work with your API, by overriding methods.

class CustomApist extends Apist {
  constructor(resource) {
    super(resource);

    // Used only when sending data.
    // By default `application/json`.
    this.contentType = 'application/json';

    // Fetch options.
    this.options = {};

    this.headers = {};
    this.host = 'http://example.com';
    this.namespace = 'api/v2';
  }

  handleError(err) {}

  // Serialization of sent data.
  serialize(data) {}

  // Deserializing the received data.
  deserialize(req, res) {}
}

API

Apist(resource)

resource

Type: string

The name of the API resource.

Instance

All CRUD methods return a Promise.

.fetchAll([query])

GET /resource?query

query

Type: object

.fetch(id, [query])

GET /resource/:id?query

id

Type: number|string

query

Type: object

.create(data)

POST /resource

data

Type: any

.update(id, data)

PUT /resource/:id

id

Type: number|string

data

Type: any

.delete(id)

DELETE /resource/:id

id

Type: any

  • redux-apist - Creator API actions for redux-thunk

License

MIT © Timofey Dergachev

Keywords

api

FAQs

Package last updated on 20 Oct 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts