Skip to content

Commit fe371cb

Browse files
committed
2 parents 75906ac + 50c9810 commit fe371cb

File tree

5 files changed

+22
-44
lines changed

5 files changed

+22
-44
lines changed

.node-version

Lines changed: 0 additions & 1 deletion
This file was deleted.

README.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,22 @@
1-
# @reststate/client
1+
# @codingitwrong/jsonapi-client
22

3-
**This package is no longer maintained.**
4-
5-
A lightweight client for making requests to a JSON:API service.
3+
A lightweight client for making requests to a [JSON:API](https://jsonapi.org/) service.
64

75
- It doesn't attempt to provide a way to utilize every possible feature of JSON:API; instead, it offers a core set of functionality sufficient for most apps.
86
- It doesn't attempt to abstract away the JSON:API object format; instead, it returns JSON:API data as-is.
97

10-
`@reststate/client` provides a simple Promise-based API suitable for just about any JavaScript application. It doesn't handle persistence, though; for that, wrappers are available for a variety of popular state stores:
11-
12-
- [Vuex](https://github.com/CodingItWrong/vuex-jsonapi)
13-
- [MobX](https://github.com/CodingItWrong/mobx-jsonapi)
14-
- Coming soon: Redux
15-
168
## Synopsis
179

1810
```javascript
11+
import { ResourceClient } from '@codingitwrong/jsonapi-client';
12+
1913
const resource = new ResourceClient({
2014
name: 'widgets',
2115
httpClient: axios.create(...),
2216
});
2317

2418
resource.all()
25-
.then(widgets => widgets);
19+
.then(response => console.log(response.data));
2620

2721
resource.create({
2822
attributes: {
@@ -34,14 +28,20 @@ resource.create({
3428
## Installation
3529

3630
```sh
37-
$ npm install --save @reststate/client
31+
$ npm install --save @codingitwrong/jsonapi-client
32+
```
33+
34+
or
35+
36+
```sh
37+
$ yarn add @codingitwrong/jsonapi-client
3838
```
3939

40-
`@reststate/client` needs to be configured with an `httpClient` object that handles the requests and responses. The easiest way to do this is to provide an `axios` instance configured with your server's base URL, the standard JSON:API content type, and optionally any authentication info your server requires.
40+
`@codingitwrong/jsonapi-client` needs to be configured with an `httpClient` object that handles the requests and responses. The easiest way to do this is to provide an [`axios`](https://axios-http.com/) instance configured with your server's base URL, the standard JSON:API content type, and optionally any authentication info your server requires.
4141

4242
```js
4343
import axios from 'axios';
44-
import { ResourceClient } from '@reststate/client';
44+
import { ResourceClient } from '@codingitwrong/jsonapi-client';
4545

4646
const token = "FILL_ME";
4747

deploy.sh

Lines changed: 0 additions & 21 deletions
This file was deleted.

docs/reading-data.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,18 @@
22

33
## all
44

5-
To retrieve all of the records for a resource, call the `all()` method. The method returns a promise that will resolve to the records:
5+
To retrieve all of the records for a resource, call the `all()` method. The method returns a promise that will resolve to the server's JSON response:
66

77
```javascript
8-
resource.all().then(widgets => console.log(widgets));
8+
resource.all().then(response => console.log(response.data));
99
```
1010

1111
## find
1212

1313
To retrieve a single record by ID, call the `find()` method:
1414

1515
```javascript
16-
resource.find({ id: 42 }).then(widget => console.log(widget));
16+
resource.find({ id: 42 }).then(response => console.log(response.data));
1717
```
1818

1919
## where
@@ -24,7 +24,7 @@ To filter/query for records based on certain criteria, use the `where` method, p
2424
const filter = {
2525
category: 'whizbang',
2626
};
27-
resource.where({ filter }).then(widgets => console.log(widgets));
27+
resource.where({ filter }).then(response => console.log(response.data));
2828
```
2929

3030
## related
@@ -37,7 +37,7 @@ const parent = {
3737
id: 27,
3838
};
3939

40-
resource.related({ parent }).then(widgets => console.log(widgets));
40+
resource.related({ parent }).then(response => console.log(response.data));
4141
```
4242

4343
By default, the name of the relationship on `parent` is assumed to be the same as the name of the other model: in this case, `widgets`. In cases where the names are not the same, you can explicitly pass the relationship name:
@@ -52,7 +52,7 @@ const relationship = 'purchased-widgets';
5252

5353
resource
5454
.related({ parent, relationship })
55-
.then(widgets => console.log(widgets));
55+
.then(response => console.log(response.data));
5656
```
5757

5858
## Options

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
2-
"name": "@reststate/client",
2+
"name": "@codingitwrong/jsonapi-client",
33
"version": "0.0.9",
44
"description": "A vanilla JS client for JSON:API services",
55
"main": "index.js",
6-
"repository": "[email protected]:reststate/reststate-client.git",
6+
"repository": "[email protected]:codingitwrong/jsonapi-client.git",
77
"author": "Josh Justice <[email protected]>",
88
"license": "Apache-2.0",
99
"scripts": {

0 commit comments

Comments
 (0)