๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ

์—๋Ÿฌ ํ•ธ๋“ค๋ง1

[React] REST API, AXIOS๋กœ ๋ฐ›์•„์˜จ Array ๊ฐ์ฒด๋ฅผ mapํ•จ์ˆ˜ ํ˜ธ์ถœ์ด ๋ถˆ๊ฐ€๋Šฅํ• ๋•Œ [React] REST API, AXIOS๋กœ ๋ฐ›์•„์˜จ Array ๊ฐ์ฒด๋ฅผ mapํ•จ์ˆ˜ ํ˜ธ์ถœ์ด ๋ถˆ๊ฐ€๋Šฅํ• ๋•Œ์ด ๊ธ€์—์„œ๋Š” React๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ REST API๋กœ๋ถ€ํ„ฐ Axios๋ฅผ ํ†ตํ•ด ๋ฐ์ดํ„ฐ๋ฅผ ๋ฐ›์•„์˜ฌ ๋•Œ ๋ฐœ์ƒํ•˜๋Š” ๋ฐฐ์—ด(Array) ๊ฐ์ฒด์˜ map ํ•จ์ˆ˜ ํ˜ธ์ถœ ์˜ค๋ฅ˜์— ๋Œ€ํ•ด ์ƒ์„ธํžˆ ์„ค๋ช…ํ•˜๊ณ , ์ด๋ฅผ ํ•ด๊ฒฐํ•˜๋Š” ๊ฐ„๋‹จํ•˜๋ฉด์„œ๋„ ํšจ๊ณผ์ ์ธ ๋ฐฉ๋ฒ•์„ ์†Œ๊ฐœํ•˜๊ณ ์ž ํ•ฉ๋‹ˆ๋‹ค. ํŠนํžˆ ๋น„๋™๊ธฐ ๋ฐ์ดํ„ฐ ์ฒ˜๋ฆฌ์™€ ๊ด€๋ จํ•˜์—ฌ Promise ๊ฐ์ฒด๊ฐ€ ํ•ด๊ฒฐ๋˜๊ธฐ ์ „์— ์ปดํฌ๋„ŒํŠธ๊ฐ€ ๋ Œ๋”๋ง๋˜์–ด ๋ฐœ์ƒํ•˜๋Š” ์˜ค๋ฅ˜์˜ ์›์ธ๊ณผ ํ•ด๊ฒฐ์ฑ…์„ ์ค‘์ ์ ์œผ๋กœ ๋‹ค๋ฃจ๋ฉฐ, ๋กœ๋”ฉ ์ƒํƒœ ๊ด€๋ฆฌ ๋ฐ ์กฐ๊ฑด๋ถ€ ๋ Œ๋”๋ง์„ ํ™œ์šฉํ•œ ์ ‘๊ทผ๋ฒ•์— ๋Œ€ํ•ด ์ด์•ผ๊ธฐํ•ฉ๋‹ˆ๋‹ค.๋„์ž…๋ถ€React๋ฅผ ์‚ฌ์šฉํ•˜๋ฉด์„œ ์„œ๋ฒ„๋กœ๋ถ€ํ„ฐ ๋ฐ์ดํ„ฐ๋ฅผ ๋ฐ›์•„์™€ ๋ Œ๋”๋งํ•˜๋Š” ๊ณผ์ •์€ ๋งค์šฐ ์ผ๋ฐ˜์ ์ž…๋‹ˆ๋‹ค. ๋งŽ์€ ๊ฐœ๋ฐœ์ž๋“ค์ด Axios๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ REST API์™€ ํ†ต์‹ ํ•˜๋ฉฐ ๋ฐ์ดํ„ฐ.. 2024. 10. 18.