Socket
Book a DemoInstallSign in
Socket

@labor-digital/json-api

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@labor-digital/json-api

Provides the implementation to communicate with an json api compatible endpoint

latest
Source
npmnpm
Version
4.0.1
Version published
Maintainers
1
Created
Source

Json API

Provides the implementation to communicate with an json api compatible endpoint. The package is build with axios as http client and utilizes jsonapi-serializer to normalize the results into javascript objectes.

Installation

Install this package using npm:

npm install @labor-digital/json-api

Usage

import {JsonApiState} from "./lib/JsonApiState"; 
import {JsonApi} from "./lib/JsonApi";

// Create the instance
const api = new JsonApi({baseUrl: "https://example.org/api/resources"});

// Request the resources of type "myResource" that are on page 2
// The query object has some types already defined but as specified in the json-api 
// definition, it can be extended with your own keys
const results = api.get("myResource", {page: {number: 2}});

// Iterate all results in the list and print the value of "myKey" into the console
results.forEach((result: JsonApiState) => {
    console.log(result.get("myKey"));
});

// You can also request a single resource by using the unique id as a lookup query
const state = api.getSingle("myResource", 12);
console.log(state.get("myKey"));

Documentation

The documentation / API can be found here but is also rendered at "./doc/index.html" for local usage

Postcardware

You're free to use this package, but if it makes it to your production environment we highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using.

Our address is: LABOR.digital - Fischtorplatz 21 - 55116 Mainz, Germany

We publish all received postcards on our company website.

FAQs

Package last updated on 07 Jun 2021

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

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.