-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: default content-type #30
base: main
Are you sure you want to change the base?
Conversation
โฆnto fix/content-type
e7e3cbf
to
f2667fc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fetch์์๋ ์๋ฌด๊ฒ๋ ์
๋ ฅํ์ง์์๋ ๋ธ๋ผ์ฐ์ ๊ฐ ์์์ content-type์ ๋ฃ์ด์ฃผ์ง๋ง, fetch-ax๋ application/json์ default๋ก ๊ฐ๊ณ ์๊ธฐ์ ํด๋น ๊ธฐ๋ฅ๋ค์ ์ ๊ณตํด์ฃผ์ง ๋ชปํ๋๊ฒ ๋ฌธ์ ์ฌ์ ํด๊ฒฐํ๊ฒ ๋ง์๊น์ ?? ๐ค
๋ฆฌ๋๋ฏธ ์์ ๊น์ง,, ๊ณ ์ ๋ง์ผ์
จ์ต๋๋ค ~!
|
||
##### headers | ||
|
||
- By default, there is no default value for headers. But it's content-type is `application/json` only if the data is `json` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
data๊ฐ json์ธ ๊ฒฝ์ฐ์๋ ์ ํฌ๊ฐ application/json์ผ๋ก "์ค์ "ํด์ฃผ๋ ๊ฒ์ด๊ธฐ์
is ๋์ is set to ์๋ก ์์ผ๋ก ์์ฑํ๋ฉด ์ด๋จ๊น์ ~?
return ( | ||
isJson(data) || // data === 'string' ์ ํตํด์๋ JSON์ธ์ง๋ฅผ ํ์ธํ ์ ์์ง๋ง ๋ช ์์ ์ผ๋ก ๋ฐ์ง๊ธฐ ์ํด์ | ||
typeof data === 'string' || | ||
data instanceof ReadableStream || | ||
(typeof ReadableStream !== 'undefined' && data instanceof ReadableStream) || |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
์ด ์ฝ๋๋ ์ด๋ค ์๋๋ก ์ถ๊ฐ๋๊ฑธ๊น์ !? ํน์ ์ด๋ค ์ค๋ฅ๋ฅผ ๋ฐ๊ฒฌํ์ จ๋์ฉ?
@@ -334,6 +341,16 @@ function isHttpError(response: Response) { | |||
return response.status >= 300; | |||
} | |||
|
|||
function appendJsonContentType( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
์ ํฌ rollup ์ฌ์ฉํ ์ดํ๋ก ํ์ผ ๋ถ๋ฆฌ๋ฅผ ์ํ๋ค์!! ์ด ๋ถ๋ถ ์ ๊ฐ ์ด์์ ์ถ๊ฐํ๊ฒ ์ต๋๋ค
๐ ์์ ๋ด์ฉ
application/json
์ content-type์ผ๋ก ์ค์ ํ๋ ๋ก์ง ์ถ๊ฐ๋ฌธ์
application/json
์ผ๋ก ์ค์ ๋์ด ์์ด ์ค๋ฅ๊ฐ ๋ฐ์ํฉ๋๋ค.๐ค ๊ณ ๋ฏผ ํ๋ ๋ถ๋ถ
fetch-ax๊ฐ content-type์ ๊ธฐ๋ณธ๊ฐ์
application/json
์ผ๋ก ์ค์ ํ ๋ชฉ์ -> fetch-ax๊ฐ content-type์ ๊ธฐ๋ณธ๊ฐ์
application/json
์ผ๋ก ์ค์ ํ ๋ชฉ์ ์ ์ถฉ์กฑ์ํค๊ธฐ ์ํด, data๊ฐ JSON type์ธ ๊ฒฝ์ฐ์ ์๋์ผ๋กapplication/json
์ content-type์ผ๋ก ์ค์ ํ๋ ๋ก์ง์ ์ถ๊ฐํด ์ด๋ฅผ ๋์๋ณ๊ฒฝ๋ ๋ก์ง
application/json
์ content-type์ผ๋ก ์ค์