GithubHelp home page GithubHelp logo

labor-digital / json-api Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 610 KB

Provides the implementation to communicate with an json api compatible endpoint

License: Apache License 2.0

JavaScript 4.48% TypeScript 95.52%

json-api's Introduction

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.

json-api's People

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.