Skip to content

peimelo/toh-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

API Server

To install and start the API server, run the following commands in this directory:

  • npm install
  • node server

Open http://localhost:3000

Using The Server

Include An Authorization Header

POST /api/sessions: returns a token in the body and also in the header. You can use this token in the following endpoints.

All requests, except POST /api/sessions, use an Authorization header, of size >= 10 characters, so that you can only manipulate your data, for example:

fetch(url, {
  headers: { Authorization: 'whatever-you-want' },
});

API Endpoint

The following endpoints are available:

Endpoints Usage Params
POST /api/sessions Authenticates the user. email - [String]
password - String]
GET /api/heroes Get all of the heroes.
GET /api/heroes?name=term Get all heroes with name like a term. term - [String]
GET /api/heroes/:id Get the details of a single hero.
POST /api/heroes Add a new hero. name - [String]
PUT /api/heroes/:id Edit the details of an existing hero. name - [String]
DELETE /api/heroes/:id Remove the hero.

Releases

No releases published

Packages

No packages published