Written by
react-style
on
on
21.12.21 코인마켓캡 API 연결
21.12.21 코인마켓캡 API 연결
API documentation
https://coinmarketcap.com/api/documentation/v1/#section/Quick-Start-Guide
import React, { useState, useEffect } from 'react' import axios from 'axios' const Prices = () => { const [ data, setData ] = useState([]) useEffect(() => { axios .get( 'https://pro-api.coinmarketcap.com/v1/cryptocurrency/listings/latest', { headers: { 'X-CMC_PRO_API_KEY': '자신의 키', }, }, ) .then((res: any) => { const DataArray = JSON.parse(res.request.response).data setData(DataArray) }) }) return ( <> {'불러온 코인 총 100개'} {data.map((item, index) => { return ( <> {item.name} {item.quote.USD.price} ) })} ) } export default Prices
from http://jemerald.tistory.com/129 by ccl(A) rewrite - 2021-12-28 10:26:47