Status Code HTTP Semantik

Gunakan HTTP status code yang tepat: 200 (OK), 201 (Created), 204 (No Content), 400 (Bad Request), 401 (Unauthorized), 403 (Forbidden), 404 (Not Found).

👀 Contoh dulu

const res = { status(c) { console.log(c); return this; }, send() {} };
res.status(204).send();

Hasilnya: 204

💡 Jangan pernah mengembalikan status 200 OK jika terjadi error di API!

📝 Sekarang giliranmu

Tuliskan perintah balasan Express untuk mengembalikan HTTP status 204 No Content tanpa payload body (res.status(204).send()).

Preview