Building and API to handle GET and POST requests to connect with the frontend project from a previous assignment.
Learning objectives:
- How to build a full API which includes handling of user input
- How to include error handling to return good validation errors
- How to build an API which works well with an existing frontend
🔵 Blue Level
- The API should be deployed to Heroku or similar hosting service.
- The database should be deployed using mongo cloud or similar.
- The API should implement the routes exactly as documented in the brief (A copy of the brief can be found in the production folder as a .pdf).
- The
GET /thoughts
endpoint should only return 20 results, ordered bycreatedAt
in descending order. - The API should validate user input and return appropriate errors if the input is invalid.
- In the
POST /thoughts
endpoint to create a new thought, if the input was invalid and the API is returning errors, it should set the response status to400
(bad request). - The endpoint to add hearts to a thought should return an appropriate error if the thought was not found.
backend: https://happy-thoughts-api-pwangy.herokuapp.com/
frontend: https://pwangy-happy-v2.netlify.app/