https://github.com/peimelo/json-server-api
https://github.com/peimelo/json-server-api
api javascript json-server
Last synced: 23 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/peimelo/json-server-api
- Owner: peimelo
- Created: 2021-02-05T22:52:22.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2021-02-05T23:22:33.000Z (over 5 years ago)
- Last Synced: 2025-05-16T07:11:27.630Z (about 1 year ago)
- Topics: api, javascript, json-server
- Language: JavaScript
- Homepage:
- Size: 27.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Json Server API
Example of how to use [Json Server](https://github.com/typicode/json-server) as API.
To install and start the API server, run the following commands in this directory:
```bash
npm install
node api
```
Open `http://localhost:3001`
## Using The API
### Include An Authorization Header
All requests should use an **Authorization header** to work with your own data:
```js
fetch(url, {
headers: { Authorization: 'whatever-you-want' },
});
```
### API Endpoint
The following endpoints are available:
| Endpoints | Usage | Params |
| ----------------------- | ------------------------------------- | ----------------------------------------------- |
| `GET /api/posts` | Get all of the posts. | |
| `POST /api/posts` | Add a new post. | **title** - [String]
**author** - [String] |
| `GET /api/posts/:id` | Get the details of a single post. | |
| `PUT /api/posts/:id` | Edit the details of an existing post. | **title** - [String]
**author** - [String] |
| `DELETE /api/posts/:id` | Delete a post. | |