-
React 에서 axios 요청하는 법axios 2023. 2. 24. 21:19
📌 axios 는 then 이라는 문법을 통해 await async promise 를 처리하고 있다고 한다.
비동기 처리 방식이라는 것은 알겠는데 정확히 무슨 말인지는 모르겠다.
차후 공부하면 다시 써보자
...(중략) interface CoinInterface { id : string , name : string, symbol : string, rank : number, is_new : boolean, is_active : boolean, type : string } function Coins() { // useState typescript 사용 const [coins , setCoins] = useState<CoinInterface[]>([]) useEffect(()=>{ axios.get('https://api.coinpaprika.com/v1/tickers').then((Response)=>{ setCoins(Response.data) }).catch((Error)=>{ console.log(Error); }) },[coins]) return ( <> ...(중략)
'axios' 카테고리의 다른 글
async await , then catch (feat. tryCatch) (0) 2023.05.11 Node.js 에서 axios 사용법 : get post put delet 및 req 로 데이터 받는 법 (0) 2023.01.30