Returns an array of all the books in the database.
- URL
/api/v1/book
-
Method:
GET
-
URL Params
Required:
-
Data Params
None
-
Success Response:
-
Code: 200
Content:[ { ID: 1, CreatedAt: "2021-09-18T22:53:18.652583692+01:00", UpdatedAt: "2021-09-18T22:53:18.652583692+01:00", DeletedAt: null, title: "1984", author: "Geroge Orwell", rating: 5, }, ];
OR
-
Code: 200
Content:[];
-
-
Sample Call:
curl GET 'http://localhost:3000/api/v1/book'
Returns json data of a single book.
- URL
/api/v1/book/:id
-
Method:
GET
-
URL Params
Required:
id=[integer]
-
Data Params
None
-
Success Response:
- Code: 200
Content:{ "ID": 1, "CreatedAt": "2021-09-18T22:53:18.652583692+01:00", "UpdatedAt": "2021-09-18T22:53:18.652583692+01:00", "DeletedAt": null, "title": "1984", "author": "Geroge Orwell", "rating": 5 }
- Code: 200
-
Error Response:
- Code: 404 NOT FOUND
Content:{ error : "Book doesn't exist" }
- Code: 404 NOT FOUND
-
Sample Call:
curl GET 'http://localhost:3000/api/v1/book/2'
Returns "Book deleted successfully".
-
URL
/api/v1/book/:id
-
Method:
DELETE
-
URL Params
Required:
id=[integer]
-
Data Params
None
-
Success Response:
- Code: 200
Content:Book deleted successfully
- Code: 200
-
Error Response:
- Code: 404 NOT FOUND
Content:No book found with given ID
OR
- Code: 401 UNAUTHORIZED
Content:{ error : "You are unauthorized to make this request." }
- Code: 404 NOT FOUND
-
Sample Call:
curl DELETE 'http://localhost:3000/api/v1/book/3'