codestates / codestates/Podo

[๐Ÿ‘พ Error] Sever: `ERR_HTTP_HEADERS_SENT`

Open
#99 0 comments 0 reactions 1 assignee Claimed by @cherishxyun View on GitHub
Error Handling Log
Dominant language
JavaScript
Stars
0
Forks
2
PR merge metrics
No merged PRs in 30d

Description

### ์—๋Ÿฌ๋ฅผ ์ƒ์„ธํžˆ ์ž‘์„ฑํ•˜์„ธ์š”

![แ„‰แ…ณแ„แ…ณแ„…แ…ตแ†ซแ„‰แ…ฃแ†บ 2021-12-01 10 52 45](https://user-images.githubusercontent.com/81494787/144159698-50eb2ad1-0fc7-44c7-b908-7c06f1faf2dd.png)

### ์—๋Ÿฌ์˜ ์›์ธ์ด ๋ฌด์—‡์ธ๊ฐ€์š”
1. ํด๋ผ์ด์–ธํŠธ์—๊ฒŒ ๋‘ ๊ฐœ ์ด์ƒ์˜ response๋ฅผ ์ „๋‹ฌํ–ˆ๊ธฐ ๋•Œ๋ฌธ์— ์—๋Ÿฌ๊ฐ€ ๋ฐœ์ƒํ–ˆ์Šต๋‹ˆ๋‹ค.
2. ์ฝ”๋“œ์—์„œ returnํ•ด์ฃผ๋Š” res๊ฐ€ ํ•˜๋‚˜๋งŒ ์žˆ๋Š” ๊ฒƒ์„ ๋ณด๊ณ  ์–ด๋””์„œ ์—๋Ÿฌ๊ฐ€ ๋‚ฌ๋Š”์ง€ ํŒŒ์•…ํ•˜๊ธฐ ์–ด๋ ค์› ์Šต๋‹ˆ๋‹ค. ๋” ์•Œ์•„๋ณด๋‹ˆ status์™€ sendStatus์˜ ์ฐจ์ด ๋•Œ๋ฌธ์— ์—๋Ÿฌ๊ฐ€ ๋ฐœ์ƒํ–ˆ์Œ์„ ์•Œ ์ˆ˜ ์žˆ์—ˆ์Šต๋‹ˆ๋‹ค.
- status(): HTTP์˜ ์ƒํƒœ๋งŒ ์ •ํ•ด์ฃผ๋Š” Method์ž…๋‹ˆ๋‹ค.
- sendStatus(): ์ƒํƒœ๋ฅผ ์ •ํ•ด์ฃผ๊ณ  'ํด๋ผ์ด์–ธํŠธ์—๊ฒŒ ๋ณด๋‚ด๋Š”' Method์ž…๋‹ˆ๋‹ค.

### ์—๋Ÿฌ๋ฅผ ์–ด๋–ป๊ฒŒ ํ•ด๊ฒฐํ–ˆ๋‚˜์š”
sendStatus์—์„œ status๋กœ ๋ฐ”๊ฟ”์ฃผ์—ˆ์Šต๋‹ˆ๋‹ค.
Before: `return res.sendStatus(200)).json({ message: "Success" });`
After: `return res.status(200).json({ message: "Success" });`

### ๊ฒ€์ƒ‰ ํ‚ค์›Œ๋“œ์™€ ๋„์›€์ด ๋œ ๋ ˆํผ๋Ÿฐ์Šค๋ฅผ ์ž‘์„ฑํ•˜์„ธ์š”
[ERR_HTTP_HADERS_SENT](https://www.codementor.io/@oparaprosper79/understanding-node-error-err_http_headers_sent-117mpk82z8)
[status์™€ sendStatus์˜ ์ฐจ์ด](https://stackoverflow.com/questions/38620682/difference-between-response-status-vs-response-sendstatus-in-express/56275083)

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.