Grokking ExpressJS
0% completed
Error Handling and Validation in APIs
A client sends {"title": "", "completed": "yes"} to POST /tasks. Suppose the API stops at the first problem it finds. It rejects the empty title, the client fixes it and sends the request again, and only then learns that "yes" is not a boolean either. With no checks at all, the API stores a task with no title and a string where a boolean belongs, and every client that later reads the list must cope with it.
Validation means checking that incoming data has the expected fields, types and limits before the API acts on it
.....
.....
.....
Like the course? Get enrolled and start learning!
Reading Progress
0%