Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RFR] Fix typos in DataProvider's documentation #3565

Merged
merged 1 commit into from
Aug 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions docs/DataProviders.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ Here is how this provider maps request types to API calls:
| `UPDATE_MANY` | Multiple calls to `PUT http://my.api.url/posts/123`
| `DELETE` | `DELETE http://my.api.url/posts/123`
| `DELETE_MANY` | Multiple calls to `DELETE http://my.api.url/posts/123`
| `GET_MANY` | `GET http://my.api.url/posts?filter={ids:[123,456,789]}`
| `GET_MANY` | `GET http://my.api.url/posts?filter={id:[123,456,789]}`
| `GET_MANY_REFERENCE` | `GET http://my.api.url/posts?filter={author_id:345}`

**Note**: The simple REST client expects the API to include a `Content-Range` header in the response to `GET_LIST` calls. The value must be the total number of resources in the collection. This allows react-admin to know how many pages of resources there are in total, and build the pagination controls.
Expand Down Expand Up @@ -400,25 +400,27 @@ export default (type, resource, params) => {
options.method = 'PUT';
options.body = JSON.stringify(params.data);
break;
case UPDATE_MANY:
case UPDATE_MANY: {
const query = {
filter: JSON.stringify({ id: params.ids }),
};
url = `${apiUrl}/${resource}?${stringify(query)}`;
options.method = 'PATCH';
options.body = JSON.stringify(params.data);
break;
}
case DELETE:
url = `${apiUrl}/${resource}/${params.id}`;
options.method = 'DELETE';
break;
case DELETE_MANY:
case DELETE_MANY: {
const query = {
filter: JSON.stringify({ id: params.ids }),
};
url = `${apiUrl}/${resource}?${stringify(query)}`;
options.method = 'DELETE';
break;
}
case GET_MANY: {
const query = {
filter: JSON.stringify({ id: params.ids }),
Expand Down Expand Up @@ -449,9 +451,10 @@ export default (type, resource, params) => {

return fetch(url, options)
.then(res => res.json())
.then(response =>
.then(response => {
/* Convert HTTP Response to Data Provider Response */
/* Covered in the next section */
}
);
};
```
Expand Down Expand Up @@ -589,16 +592,16 @@ POST http://path.to.my.api/posts
PUT http://path.to.my.api/posts/123
{ "id": 123, "title": "hello, world", "author_id": 12 }

PUT http://path.to.my.api/posts?filter={ids:[123,124,125]}
PUT http://path.to.my.api/posts?filter={id:[123,124,125]}
[123, 124, 125]

DELETE http://path.to.my.api/posts/123
{ "id": 123, "title": "hello, world", "author_id": 12 }

DELETE http://path.to.my.api/posts?filter={ids:[123,124,125]}
DELETE http://path.to.my.api/posts?filter={id:[123,124,125]}
[123, 124, 125]

GET http://path.to.my.api/posts?filter={ids:[123,124,125]}
GET http://path.to.my.api/posts?filter={id:[123,124,125]}
[
{ "id": 123, "title": "hello, world", "author_id": 12 },
{ "id": 124, "title": "good day sunshine", "author_id": 12 },
Expand Down
2 changes: 1 addition & 1 deletion docs/Tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -791,7 +791,7 @@ For instance, let's imagine you have to use the `my.api.url` REST API, which exp
|---------------------|---------------------- |
| Get list | `GET http://my.api.url/posts?sort=['title','ASC']&range=[0, 24]&filter={title:'bar'}` |
| Get one record | `GET http://my.api.url/posts/123` |
| Get several records | `GET http://my.api.url/posts?filter={ids:[123,456,789]}` |
| Get several records | `GET http://my.api.url/posts?filter={id:[123,456,789]}` |
| Update a record | `PUT http://my.api.url/posts/123` |
| Create a record | `POST http://my.api.url/posts/123` |
| Delete a record | `DELETE http://my.api.url/posts/123` |
Expand Down