An open API service indexing awesome lists of open source software.

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

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. | |