Components to communicate with a jsonapi

[ This description is mirrored from README.md at github.com/morbidick/jsonapi-helpers on 2019-05-10 ]

Polymer 2 components to communicate with a jsonapi

Published on webcomponents.org Build Status

Components to communicate with an api, according to the jsonapi spec.

Components

<jsonapi-resource>

Interact with a jsonapi resource endpoint. Items can be fetched, created, updated and deleted.

<jsonapi-resource
  id="getExample"
  api-url="http://example.net"
  resource="books"
  response="{{ my_response }}"
  auto-get
></jsonapi-resource>

<jsonapi-resource
  id="getOneExample"
  api-url="http://example.net"
  resource="books"
  resourceId="1"
  response="{{ my_response }}"
  auto-get
></jsonapi-resource>

<jsonapi-resource
  id="saveExample"
  api-url="http://example.net"
  resource="books"
></jsonapi-resource>
<script>
  let resource = this.$.saveExample;
  resource.data = { title: 'awesome book', author: 'morbidick' };
  resource.save();
</script>

<jsonapi-settings>

Set api settings once globally. For now they can't be overwritten on the jsonapi-resource element.

<jsonapi-settings
  api-url="http://example.net"
></jsonapi-settings>

<jsonapi-resource
  resource="books"
  response="{{ my_response }}"
  auto-get
></jsonapi-resource>

<jsonapi-error-toast>

"Singleton Element" to display a toast with the error details if any <jsonapi-resource> on the site encounters an error.

<jsonapi-error-toast></jsonapi-error-toast>
<jsonapi-resource
  resource="undefined_endpoint"
  auto-get
></jsonapi-resource>

Development

# Get dependencies
$ npm install

# Demo site
$ npm start

# Run tests
$ npm test

Install

Link to this version
ImportedReleased 08 November 2017MIT License
Framework Support
Polymer 2.0+
Browser Independent
Install with
bower install --save morbidick/jsonapi-helpers"#2.1.0"
Run the above Bower command in your project folder. If you have any issues installing, please contact the author.
Release notes - Version 2.1.0

Dependencies

  • polymer#Polymer/polymer#^2.0.0
  • paper-toast#PolymerElements/paper-toast#^2.0.0
  • paper-tooltip#PolymerElements/paper-tooltip#^2.0.0
  • iron-icons#PolymerElements/iron-icons#^2.0.0