A successful click is not a saved record
The practice app displays a confirmation after this function resolves. The API can return 400 for invalid input.
javascript
async function saveSession(session) {
const response = await fetch("/api/sessions", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(session)
});
return response.json();
}- 1
Trace
What does this function send, and what value does it return?
- 2
Find the gap
A response with status 400 contains valid JSON. Does this function reject because of that HTTP status?
- 3
Improve
Name the smallest fix and the two response cases you would verify.
Your explanation
Use your own words. Include the evidence you would look for and the assumptions you are making.
Use synthetic information only. Notes are saved when you choose Save practice.
Sign in before writing to save your explanation and self-assessment to your account.
Sign in