Skip to content
Stephen McBride edited this page Nov 23, 2020 · 24 revisions

Create Board

Creates board based on provided params.

Authentication

Requires session cookie.

URL

POST /boards

Request Form Data

Parameter Type Description Requirement Type
user_id integer ID of the user creating the board. Required
name string Desired name of the board being created. Required

Example Request

let formData = new FormData();
formData.append(board["user_id"], 1);
formData.append(board["name"], "My Board");

fetch(`http://localhost:3000/boards`, {
    credentials: 'include',
    method: 'post',
    body: formData
}).then(response => response.json())
  .then(json => ...);

Response Parameters

Parameter Type Description
board_id integer ID of the created board.
user_id integer User ID of the created board.
name string Name of the created board.

Example Response

{
	"board_id": 1, "user_id": 1, "name": "My Board"
}

Index Boards

Shows all boards belonging to a user.

Authentication

Requires session cookie.

URL

GET /boards

Request Form Data

Parameter Type Description Requirement Type
user_id integer ID of the user that owns the board. Required

Example Request

let formData = new FormData();
formData.append(board["user_id"], 1);

fetch(`http://localhost:3000/boards`, {
    credentials: 'include',
    method: 'get',
    body: formData
}).then(response => response.json())
  .then(json => ...);

Response

Parameter Type Description
board_id integer ID of the requested board.
user_id integer User ID of the requested board.
name string Name of the requested board.

Example Response

[
	{
		"board_id": 1,
		"user_id": 1,
		"name": "My Board"
	},
	{
		"board_id": 2,
		"user_id": 1,
		"name": "My Second Board"
	}
]

Show Board

Shows specific board.

Authentication

Requires session cookie.

URL

GET /boards/:board_id

Request Form Data

None.

Example Request

fetch(`http://localhost:3000/boards/1`, {
    credentials: 'include',
    method: 'get',
}).then(response => response.json())
  .then(json => ...);

Response

Parameter Type Description
board_id integer ID of the requested board.
user_id integer User ID of the requested board.
name string Name of the requested board.

Example Response

{
	"board_id": 1,
	"user_id": 1,
	"name": "My Board"
}

Update Board

Updates specific board.

Authentication

Requires session cookie.

URL

PUT /boards/:board_id

Request Form Data

Parameter Type Description Requirement Type
user_id integer ID of the user that owns the board. Optional
name string Desired name of the board being updated. Optional

Example Request

let formData = new FormData();
formData.append(board["user_id"], 1);
formData.append(board["name"], "Updated Name");

fetch(`http://localhost:3000/boards/1`, {
    credentials: 'include',
    method: 'put',
    body: formData
}).then(response => response.json())
  .then(json => ...);

Response

Parameter Type Description
board_id integer ID of the updated board.
user_id integer User ID of the updated board.
name string Name of the updated board.

Example Response

{
	"board_id": 1,
	"user_id": 1,
	"name": "My Board"
}

Destroy Board

Destroys specific board.

Authentication

Requires session cookie.

URL

DELETE /boards/:board_id

Request Form Data

None.

Example Request

fetch(`http://localhost:3000/boards/1`, {
    credentials: 'include',
    method: 'delete',
}).then(response => response.json())
  .then(json => ...);

Response

None.