mirror of
https://github.com/FranP-code/Crypto-Prices.git
synced 2025-10-12 23:53:06 +00:00
Console.logs removed
This commit is contained in:
@@ -138,8 +138,6 @@ const Crypto = () => {
|
|||||||
days -= 1
|
days -= 1
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(days)
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
const requestData = await fetch(`https://api.coingecko.com/api/v3/coins/${cryptoID}/market_chart?vs_currency=usd&days=${days}&interval=daily`)
|
const requestData = await fetch(`https://api.coingecko.com/api/v3/coins/${cryptoID}/market_chart?vs_currency=usd&days=${days}&interval=daily`)
|
||||||
@@ -170,7 +168,6 @@ const Crypto = () => {
|
|||||||
const effectHandler = async () => {
|
const effectHandler = async () => {
|
||||||
|
|
||||||
const data = await getCryptoData()
|
const data = await getCryptoData()
|
||||||
console.log(data);
|
|
||||||
|
|
||||||
const cryptoPricesPrevious = {}
|
const cryptoPricesPrevious = {}
|
||||||
cryptoPricesPrevious.week = await getCryptoPrice(7)
|
cryptoPricesPrevious.week = await getCryptoPrice(7)
|
||||||
@@ -186,7 +183,6 @@ const Crypto = () => {
|
|||||||
datesPrevious.year = getDates(365)
|
datesPrevious.year = getDates(365)
|
||||||
setDates(datesPrevious)
|
setDates(datesPrevious)
|
||||||
|
|
||||||
console.log(dates);
|
|
||||||
|
|
||||||
const maxValue = Math.max(...cryptoPricesPrevious.year)
|
const maxValue = Math.max(...cryptoPricesPrevious.year)
|
||||||
const minValue = Math.min(...cryptoPricesPrevious.year)
|
const minValue = Math.min(...cryptoPricesPrevious.year)
|
||||||
|
|||||||
@@ -79,7 +79,6 @@ const CryptoGallery = ({setLoading, setLoadingURL, loading}) => {
|
|||||||
let data = await fetch("https://api.coingecko.com/api/v3/coins/markets?vs_currency=usd&per_page=30&order=gecko_desc")
|
let data = await fetch("https://api.coingecko.com/api/v3/coins/markets?vs_currency=usd&per_page=30&order=gecko_desc")
|
||||||
data = await data.json()
|
data = await data.json()
|
||||||
|
|
||||||
console.log(data)
|
|
||||||
return data
|
return data
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -92,12 +91,9 @@ const CryptoGallery = ({setLoading, setLoadingURL, loading}) => {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
console.log(data.id)
|
|
||||||
let requestData = await fetch(`https://api.coingecko.com/api/v3/coins/${data.id}/market_chart?vs_currency=usd&days=6&interval=daily`)
|
let requestData = await fetch(`https://api.coingecko.com/api/v3/coins/${data.id}/market_chart?vs_currency=usd&days=6&interval=daily`)
|
||||||
requestData = await requestData.json()
|
requestData = await requestData.json()
|
||||||
|
|
||||||
console.log(requestData)
|
|
||||||
|
|
||||||
return requestData.prices
|
return requestData.prices
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -128,7 +124,6 @@ const CryptoGallery = ({setLoading, setLoadingURL, loading}) => {
|
|||||||
const lastDayPrices = localStorage.getItem('lastDayPrices')
|
const lastDayPrices = localStorage.getItem('lastDayPrices')
|
||||||
const actualDay = moment().format('DD-MM-YYYY')
|
const actualDay = moment().format('DD-MM-YYYY')
|
||||||
|
|
||||||
console.log(actualDay)
|
|
||||||
setDates(generateArrayOfDates())
|
setDates(generateArrayOfDates())
|
||||||
|
|
||||||
// In the case the las day prices are today, just restore them from Local Storage
|
// In the case the las day prices are today, just restore them from Local Storage
|
||||||
@@ -136,16 +131,12 @@ const CryptoGallery = ({setLoading, setLoadingURL, loading}) => {
|
|||||||
|
|
||||||
const prices = JSON.parse(localStorage.getItem('prices'))
|
const prices = JSON.parse(localStorage.getItem('prices'))
|
||||||
|
|
||||||
console.log('Prices accessed from LocalStorage')
|
|
||||||
console.log(lastDayPrices)
|
|
||||||
|
|
||||||
setCryptosPrices(prices)
|
setCryptosPrices(prices)
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// If not, extract all them from the API
|
// If not, extract all them from the API
|
||||||
console.log('Prices accessed from API')
|
|
||||||
|
|
||||||
let cryptoPricesCopy = []
|
let cryptoPricesCopy = []
|
||||||
|
|
||||||
@@ -160,7 +151,6 @@ const CryptoGallery = ({setLoading, setLoadingURL, loading}) => {
|
|||||||
setLoadingURL(object.image)
|
setLoadingURL(object.image)
|
||||||
|
|
||||||
let requestData = await getCryptoPrices(object)
|
let requestData = await getCryptoPrices(object)
|
||||||
console.log(requestData)
|
|
||||||
|
|
||||||
requestData = requestData.map(arr => {
|
requestData = requestData.map(arr => {
|
||||||
|
|
||||||
@@ -168,7 +158,6 @@ const CryptoGallery = ({setLoading, setLoadingURL, loading}) => {
|
|||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
console.log(requestData)
|
|
||||||
|
|
||||||
let objectResult = {}
|
let objectResult = {}
|
||||||
objectResult[object.id] = {}
|
objectResult[object.id] = {}
|
||||||
@@ -177,7 +166,6 @@ const CryptoGallery = ({setLoading, setLoadingURL, loading}) => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
await setCryptosPrices(await cryptoPricesCopy)
|
await setCryptosPrices(await cryptoPricesCopy)
|
||||||
console.log(await cryptosPrices)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
@@ -189,15 +177,12 @@ const CryptoGallery = ({setLoading, setLoadingURL, loading}) => {
|
|||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
|
|
||||||
console.log(cryptosPrices)
|
|
||||||
|
|
||||||
//Once prices are loaded into the state...
|
//Once prices are loaded into the state...
|
||||||
if (cryptosPrices) {
|
if (cryptosPrices) {
|
||||||
|
|
||||||
//Almacenate prices on LocalStorage
|
//Almacenate prices on LocalStorage
|
||||||
const jsonString = JSON.stringify(cryptosPrices)
|
const jsonString = JSON.stringify(cryptosPrices)
|
||||||
localStorage.setItem('prices', jsonString)
|
localStorage.setItem('prices', jsonString)
|
||||||
console.log(JSON.parse(localStorage.getItem('prices')))
|
|
||||||
|
|
||||||
//Almacenate actual day on LocalStorage
|
//Almacenate actual day on LocalStorage
|
||||||
const actualDay = moment().format('DD-MM-YYYY')
|
const actualDay = moment().format('DD-MM-YYYY')
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ const CryptoGalleryItem = ({CryptoStyles, data, cryptoPrices, dates, index, cryp
|
|||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
|
|
||||||
// console.log(cryptoPrices[data.id].prices)
|
// (cryptoPrices[data.id].prices)
|
||||||
|
|
||||||
if (!cryptoPrices[data.id]) {
|
if (!cryptoPrices[data.id]) {
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user