-
[JS] chapter21. ๋น๋๊ธฐ3 - fetch APIcodeStates front-end/Java Script 2023. 1. 19. 17:35๋ฐ์ํ
๐ ๋น๋๊ธฐ
๋น๋๊ธฐ ์ฒ๋ฆฌ๋, ํน์ ์ฝ๋์ ์คํ์ด ์๋ฃ๋ ๋๊น์ง ๊ธฐ๋ค๋ฆฌ์ง ์๊ณ ๋ค์ ์ฝ๋๋ฅผ ์ํํ๋ ๊ฒ
js๋ ์ฑ๊ธ ์ค๋ ๋ ๊ธฐ๋ฐ ๋์ ์ธ์ด๋ผ์ ๋๊ธฐ์ ์๋์ด์ง๋ง ํ๊ฒฝ(๋ฐํ์)์์ ๋น๋๊ธฐ ์ฒ๋ฆฌ๋ฅผ ๋์์ฃผ๊ธฐ ๋๋ฌธ์
๋น๋๊ธฐ ์ฒ๋ฆฌ ๋ํ ๊ฐ๋ฅํ๋ค.
๐ป fetch API
๋น๋๊ธฐ ์์ฒญ์ ๊ฐ์ฅ ๋ํ์ ์ธ ์ฌ๋ก๋๋คํธ์ํฌ ์์ฒญ์ด๋ค.
๊ทธ ์ค URL ์์ฒญํ๋ ๊ฒ์ ๊ฐ๋ฅํ๊ฒ ํด ์ฃผ๋ API๊ฐ fetch API์ด๋ค.
fetch API - ํน์ URL๋ก๋ถํฐ ์ ๋ณด๋ฅผ ๋ฐ์์ค๋ ์ญํ
์์ ์ฝ๋
let url = "https://koreanjson.com/posts/1"; fetch(url) .then((response) => response.json()) .then((json) => console.log(json)) .catch((error) => console.log(error));
๋ฐ์ํ'codeStates front-end > Java Script' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[JS] chapter22. ๋น๋๊ธฐ4 - Axios (0) 2023.01.19 [JS] ์ค์ต - fetch API (0) 2023.01.19 [JS] chapter20. ๋น๋๊ธฐ2 - node.js (0) 2023.01.19 [JS] ์ค์ต - ํ์ด๋จธ API (0) 2023.01.18 [JS] chapter19. ๋น๋๊ธฐ1 - java script (0) 2023.01.17