Socket
Socket
Sign inDemoInstall

apist

Package Overview
Dependencies
18
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    apist

Simple REST API client


Version published
Weekly downloads
4
Maintainers
1
Created
Weekly downloads
 

Readme

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

FAQs

Last updated on 20 Oct 2019

Did you know?

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc