All Projects → henvo → Ra Jsonapi Client

henvo / Ra Jsonapi Client

Licence: mit
JSON API data provider for react-admin.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Ra Jsonapi Client

Permission Manager
Permission Manager is a project that brings sanity to Kubernetes RBAC and Users management, Web UI FTW
Stars: ✭ 753 (+1406%)
Mutual labels:  oss
Timed Backend
Django API for the Timed application
Stars: ✭ 15 (-70%)
Mutual labels:  jsonapi
Comcast.github.io
The main Open Source portal for Comcast
Stars: ✭ 36 (-28%)
Mutual labels:  oss
Zpan
A self-hosted cloud disk base on the cloud storage./ 一个基于云存储的网盘系统,用于自建私人网盘或企业网盘。
Stars: ✭ 765 (+1430%)
Mutual labels:  oss
Rocketz
Upload and distribute assets to OSS providers
Stars: ✭ 9 (-82%)
Mutual labels:  oss
Aliyun Oss
Aliyun oss for Laravel5, also support flysystem adapter
Stars: ✭ 31 (-38%)
Mutual labels:  oss
Oneblog
👽 OneBlog,一个简洁美观、功能强大并且自适应的Java博客
Stars: ✭ 678 (+1256%)
Mutual labels:  oss
Fabric8 Wit
wit stands for Work Item Tracker
Stars: ✭ 43 (-14%)
Mutual labels:  jsonapi
Go Demo
Go语言实例教程从入门到进阶,包括基础库使用、设计模式、面试易错点、工具类、对接第三方等
Stars: ✭ 881 (+1662%)
Mutual labels:  oss
Webpack Alioss Plugin
阿里 oss-webpack 自动上传插件
Stars: ✭ 35 (-30%)
Mutual labels:  oss
Uke Dashboard
基于 React 的前后端完全分离的管理系统前端模块
Stars: ✭ 5 (-90%)
Mutual labels:  react-admin
Grpc Jersey
gRPC<->Jersey bridge
Stars: ✭ 23 (-54%)
Mutual labels:  oss
Mahapps.metro
A framework that allows developers to cobble together a better UI for their own WPF applications with minimal effort.
Stars: ✭ 8,023 (+15946%)
Mutual labels:  oss
Aliyungo
Go SDK for Aliyun (Alibaba Cloud) - Golang API for ECS, OSS, DNS, SLB, RDS, RAM, MNS, STS, SLS, MQ, Push, OpenSearch, DM, Container Service etc.
Stars: ✭ 756 (+1412%)
Mutual labels:  oss
Ts Angular Jsonapi
JsonApi library for AngularJS + Typescript 👌
Stars: ✭ 39 (-22%)
Mutual labels:  jsonapi
Aliyun Sdk Js
阿里云 SDK for Javascript,支持在浏览器和 Nodejs 环境使用,支持大部分阿里云服务。
Stars: ✭ 727 (+1354%)
Mutual labels:  oss
Saasify
The easiest way to monetize your API. 🚀
Stars: ✭ 912 (+1724%)
Mutual labels:  oss
Jsonapi parameters
Rails-way to consume JSON:API input
Stars: ✭ 50 (+0%)
Mutual labels:  jsonapi
Waliyun
阿里云Node.js Open API SDK(完整版)
Stars: ✭ 40 (-20%)
Mutual labels:  oss
Argo
JSON API (jsonapi.org) implementation for Clojure
Stars: ✭ 34 (-32%)
Mutual labels:  jsonapi

ra-jsonapi-client

Build Status npm version

A JSONAPI compatible data provider for react-admin.

Features

Currently these actions are supported:

  • GET_LIST
  • GET_ONE
  • CREATE
  • UPDATE
  • DELETE
  • GET_MANY
  • GET_MANY_REFERENCE

Installation

# via npm
npm install ra-jsonapi-client

# via yarn
yarn add ra-jsonapi-client

Usage

Import this package, set the base url and pass it as the dataProvider to react-admin.

//in app.js
import React from "react";
import { Admin, Resource } from "react-admin";
import jsonapiClient from "ra-jsonapi-client";

const dataProvider = jsonapiClient('http://localhost:3000');

const App = () => (
  <Admin dashboard={Dashboard} dataProvider={dataProvider}>
    ...
  </Admin>
);

export default App;

Options

This client allows you to set some optional settings as the second parameter:

// Configure some settings.
const settings = { ... };

// Pass it as the second parameter after the base URL.
const dataProvider = jsonapiClient('http://localhost:3000', settings);

Total count

Since JSONAPI does not specify a standard for the total count key in the meta object, you can set it with:

const settings = { total: 'total-count' };

Which will work for:

{
  "data": { ... },
  "meta": {
    "total-count": 436
  }
}

If this option is not set it will fall back to total.

In addition, if your server doesn't provide a count field, you can set total count to null, and the provider will assume the total count is the same as the length of the data array:

const dataProvider = jsonapiClient('http://localhost:3000', { total: null });

Custom HTTP headers

Custom headers can be set by providing a headers object in options:

const settings = {
  headers: {
    Authorization: 'Bearer ...',
    'X-Requested-With': 'XMLHttpRequest'
  }
}

The default value is:

{
  Accept: 'application/vnd.api+json; charset=utf-8',
  'Content-Type': 'application/vnd.api+json; charset=utf-8',
}

Authentication

This client assumes that you are using an authProvider for your react-admin application. In order to use authentication with your backend your authProvider needs to store credentials in localStorage.

Basic auth

For basic auth your authProvider needs to store username and password like this:

localStorage.setItem('username', 'bob');
localStorage.setItem('password', 'secret');

Bearer Token

For authentication via (access) token your authProvider needs to store the token like this:

localStorage.setItem('token', '123token');

Update method (PUT vs. PATCH)

First versions used PUT as the default update HTTP method. In version 0.5.0 this was changed to PATCH since it complies with the JSONAPI standard.. You can still use PUT by declaring the update method in the settings:

{
  // Set the update method from PATCH to PUT.
  updateMethod: 'PUT'
}

Array format for GET_MANY filter

This package makes usage of the aweseome qs querystring parsing library.

Default: brackets Options: indices, repeat, comma

Contributors

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].