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 (
<>
<Text>{'불러온 코인 총 100개'}</Text>
{data.map((item, index) => {
return (
<>
<Text key={index}>{item.name}</Text>
<Text>{item.quote.USD.price}</Text>
</>
)
})}
</>
)
}
export default Prices
'react native' 카테고리의 다른 글
21.12.28 Possible Unhandled Promise Rejection (id: n): (0) | 2021.12.28 |
---|---|
21.12.28 Require cycles are allowed, but can result in uninitialized values. (0) | 2021.12.28 |
21.12.17 each child in a list should have a unique key prop (0) | 2021.12.17 |
21.12.16 ScrollView 수평으로 (0) | 2021.12.16 |
21.12.12 ImageBackground (0) | 2021.12.12 |