Last active
December 10, 2021 07:48
-
-
Save ThaddeusJiang/d0284f946aef219366a31fcb7d6bd485 to your computer and use it in GitHub Desktop.
RESTful API CRUD 设计参考
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | |
``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Should create, update, delete return full data?