Skip to content

Instantly share code, notes, and snippets.

@ThaddeusJiang
Last active December 10, 2021 07:48
Show Gist options
  • Save ThaddeusJiang/d0284f946aef219366a31fcb7d6bd485 to your computer and use it in GitHub Desktop.
Save ThaddeusJiang/d0284f946aef219366a31fcb7d6bd485 to your computer and use it in GitHub Desktop.
RESTful API CRUD 设计参考
| Method name | API call |
| :----------------- | :----------------------------------------------------------- |
| `getList` | `GET http://my.api.url/posts?sort=["title","ASC"]&range=[0, 24]&filter={"title":"bar"}` |
| `getOne` | `GET http://my.api.url/posts/123` |
| `getMany` | `GET http://my.api.url/posts?filter={"ids":[123,456,789]}` |
| `getManyReference` | `GET http://my.api.url/posts?filter={"author_id":345}` |
| `create` | `POST http://my.api.url/posts` |
| `update` | `PUT http://my.api.url/posts/123` |
| `updateMany` | Multiple calls to `PUT http://my.api.url/posts/123` |
| `delete` | `DELETE http://my.api.url/posts/123` |
| `deleteMany` | Multiple calls to `DELETE http://my.api.url/posts/123` |
ref: https://marmelab.com/react-admin/DataProviders.html#usage
header
```
Content-Range: posts 0-24/319
```
if your API is on another domain as the JS code, you’ll need to whitelist this header with an Access-Control-Expose-Headers CORS header.
```
Access-Control-Expose-Headers: Content-Range
```
@ThaddeusJiang
Copy link
Author

Should create, update, delete return full data?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment