Registry / testing / aor-json-rest-client

aor-json-rest-client

JSON →
library2.1.0jsnpmunverified

A local, in-memory REST client for admin-on-rest (AOR) that uses a JavaScript object as a data source. Version 2.1.0 is the latest stable release; the package is unmaintained since admin-on-rest has been superseded by react-admin. It serves for prototyping and testing without a backend, using Fakerest under the hood. Unlike a real HTTP client, all data changes are lost on page refresh, and it is explicitly not for production use. The package is designed solely for the now-deprecated admin-on-rest framework (v1.x).

npm install aor-json-rest-client
INSTALL
IMPORT
SIG · AOR-JSON-REST-CLIE
A
aor-json-rest-client
testingjavascriptv2.1.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default (jsonRestClient)
import jsonRestClient from 'aor-json-rest-client'
const jsonRestClient = require('aor-json-rest-client')
CommonJS require may break depending on bundler; ES import is standard.
default (jsonRestClient)
const jsonRestClient = require('aor-json-rest-client').default
const jsonRestClient = require('aor-json-rest-client')
If using CommonJS with default export, must access .default.
jsonRestClient
import { jsonRestClient } from 'aor-json-rest-client'
import jsonRestClient from 'aor-json-rest-client'
Named export is deprecated; prefer default export.

Demonstrates how to set up an admin-on-rest app with an in-memory data object as the REST client.

import React from 'react'; import { Admin, Resource } from 'admin-on-rest'; import jsonRestClient from 'aor-json-rest-client'; import { PostList } from './posts'; const data = { posts: [ { id: 0, title: 'Hello, world!' }, { id: 1, title: 'FooBar' }, ], }; const App = () => ( <Admin restClient={jsonRestClient(data, true)}> <Resource name="posts" list={PostList} /> </Admin> ); export default App;
Debug
Known issues
deprecatedadmin-on-rest is deprecated; this package is unmaintained.
fix
Migrate to react-admin and use ra-data-simple-rest or ra-data-json-server.
affects: >=2.0.0
breakingData is lost on page refresh; do NOT use in production.
fix
Switch to a persistent REST client like ra-data-simple-rest.
affects: >=1.0.0
gotchaThe second argument to jsonRestClient is 'loggingEnabled' (default false), but it is named poorly. Not a callback.
fix
Pass a boolean as second argument to enable logging.
affects: >=1.0.0
deprecatedDefault export is preferred; named export { jsonRestClient } is deprecated.
fix
Use import jsonRestClient from 'aor-json-rest-client'.
affects: >=2.0.0
Errors
Common errors & fixes
Cannot find module 'aor-json-rest-client'
Package not installed or misconfigured.
fix
npm install --save-dev aor-json-rest-client
TypeError: jsonRestClient is not a function
Using default import incorrectly with CommonJS ('require').
fix
Use ES import: import jsonRestClient from 'aor-json-rest-client'
Error: Invalid REST client: expected a function
Passing an object instead of the result of jsonRestClient().
fix
<Admin restClient={jsonRestClient(data)}>
Upgrade
Version history
2.1.0latest on npm
Audit
Dependencies
admin-on-restrequiredpeer dependency; this client is built specifically for admin-on-rest's restClient interface
fakerestrequireddirect dependency for simulating REST-like behavior in memory
Agent activity
33 hits · last 30 days
node
28
OpenAI (training)
1
Resources
aor-json-rest-client — npm install aor-json-rest-client · libregistry