Rules Hub
Coding Rules Library
← Back to all rules
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
backend ruleP2stack specificStack: node
httpfetchheaders
Set the correct request headers for what the call does
Don't send Content-Type on a request that has no body; use Accept to declare the response format you want to receive.
PR: hegnar-forum-web · org-mining-hist-2026-06Created: Jun 20, 2026
Bad example
Old codetypescript
| 1 | // GET with no body, yet declaring it sends JSON |
| 2 | const response = await fetch(url, { |
| 3 | headers: { 'Content-type': 'application/json;' }, |
| 4 | }); |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | const response = await fetch(url, { |
| 2 | headers: { Accept: 'application/json, */*' }, |
| 3 | }); |
Explanation (EN)
Objašnjenje (HR)