tezvyn:

Write a createUser function that POSTs JSON via fetch

Source: developer.mozilla.orgbeginner

WHAT IT TESTS: precise fetch configuration for JSON POST requests. A strong answer names method POST, headers Content-Type application/json, and body JSON.stringify(data) with return typing. Red flag: passing the raw object as body or omitting headers.

WHAT IT TESTS: Whether you understand the three mandatory fetch options for a JSON POST and can express them correctly in TypeScript. A good answer covers: first, method set to POST; second, headers including Content-Type application/json; third, body set to JSON.stringify(data); fourth, awaiting the response and handling ok status before parsing. Red flag: treating fetch as fire-and-forget, forgetting JSON.stringify so the server receives object Object, or returning the raw Response instead of parsed JSON.

Read the original → developer.mozilla.org

Get five bites like this every day.

Tezvyn delivers a daily feed of 60-second tech bites with quizzes to lock in what you learn.

Write a createUser function that POSTs JSON via fetch · Tezvyn