Menu

Post image 1
Post image 2
1 / 2
0

HTTP Status Codes: The Complete Developer Reference

DEV Community·Alex Chen·17 days ago
#GAycHTsd
#api#backend#tutorial#webdev#status#error
Reading 0:00
15s threshold

HTTP Status Codes: The Complete Developer Reference Stop guessing what status code to return. Use this guide. 2xx — Success Code Name When to Use 200 OK Successful GET, PUT, DELETE, or PATCH 201 Created Resource successfully created. Include Location header 202 Accepted Request accepted but not yet processed (async operations) 204 No Content Successful DELETE or PUT where no body is needed // 200 — Standard success res . status ( 200 ). json ({ data : user }); // 201 — Resource created res . status ( 201 ). json ({ data : newUser }). location ( ' /api/users/123 ' ); // 202 — Async task started res . status ( 202 ). json ({ jobId : ' abc123 ' , status : ' pending ' , checkUrl : ' /api/jobs/abc123 ' }); // 204 — Deleted successfully res . status ( 204 ). send (); // No body!…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.

Read More