Uncaught TypeError: ~~.map is not a function
728x90

์–ด๋–ค ์—๋Ÿฌ?

Uncaught TypeError: ~~. map is not a function

 

API ํ˜ธ์ถœ ์ค‘์— ์œ ๋… ํ•œ API ๋งŒ ์ด๋Ÿฐ ์—๋Ÿฌ๊ฐ€ ๋ฐœ์ƒ...

์Šคํƒ์˜ค๋ฒ„ํ”Œ๋กœ์šฐ๋ฅผ ๋ณด๋‹ˆ ์˜ค๋ธŒ์ ํŠธ๋Š” map ๋ฉ”์„œ๋“œ๋ฅผ ๊ฐ–๊ณ  ์žˆ์ง€ ์•Š์•„์„œ ์‚ฌ์šฉํ•  ์ˆ˜๊ฐ€ ์—†๋‹ค~ ์ด๋Ÿฐ ์–˜๊ธฐ๋“ค์ด ๋งŽ์•˜๋Š”๋ฐ,

๋‚˜๋Š” ๋‹น์—ฐํžˆ ๋ฐฐ์—ด๋กœ ์ž˜ ๋นผ์™”๋Š”๋ฐ ๋ฌด์Šจ ๋ง์ด์•ผ?.. ํ•˜๊ณ  ์žˆ์—ˆ๋˜ ๊ฒƒ์ด๋‹ค ^^..

 

 

  const getTeamsData = async (companyId) => {
    try {
      const response = await axios.get(
        `~~~API ์ฃผ์†Œ`
      );

      setTeamsData(response.data.teams);
    } catch (error) {
      console.log(error);
    }
  };

ํ˜„์žฌ API ํ˜ธ์ถœ ํ•จ์ˆ˜์—์„œ๋Š” ๋ฐ”๋กœ ๋ฐฐ์—ด์„ state๋กœ ์ €์žฅํ•˜๊ณ  ์žˆ์—ˆ๊ธฐ ๋•Œ๋ฌธ..

๊ทธ๋ ‡๊ฒŒ ์‹œ์ž‘๋œ ์‚ฝ์งˆ ํƒ€์ž„..

 

ํ•ด๊ฒฐ

๋„ˆ๋ฌด๋‚˜ ์–ด์ด์—†๊ฒŒ ํ•ด๊ฒฐํ•ด ๋ฒ„๋ ธ๋‹ค.

์ดˆ๊ธฐ๊ฐ’์„ ์™œ์ธ์ง€ ๊ฐ์ฒด๋กœ ํ•ด๋‘๊ณ  ์žˆ์—ˆ๋˜ ๊ฒƒ์ด์—ˆ๋‹ค.. ๐Ÿ˜‚

 

 const [teamsData, setTeamsData] = useState([]);

๋ฐฐ์—ด๋กœ ๋ฐ”๊พธ์–ด์ฃผ๋‹ˆ ํ•ด๊ฒฐ ์™„.
๋‚ด ์ฝ”๋“œ๋ฅผ ํ•ญ์ƒ ์˜์‹ฌํ•˜๋„๋ก ํ•˜์ž..

728x90