Open mayanksinha9 opened 4 years ago
import axios from 'axios';
const url='https://api.apify.com/v2/key-value-stores/toDWvRj1JpTXiM8FF/records/LATEST?disableRedirect=true';
export const fetchData=async()=>{ try{ const {data:{activeCases,recovered,deaths,lastUpdatedAtApify}}= await axios.get(url);
return {activeCases,recovered,deaths,lastUpdatedAtApify};
}
catch(error){
}
}
export const fetchRegionData= async()=>{
try{
const{data}=await axios.get(${url}/regionData
);
const modifiedData=data.map((regionData)=>({
totalInfected:regionData.totalInfected,
recovered:regionData.recovered,
deceased:regionData.deceased,
}));
return modifiedData; }
catch(error){
}
}``
Hi, kindly provide a github link to your code or the error information so that we can identify where it is breaking.
import React,{useState,useEffect} from 'react'; import { fetchRegionData } from '../../api';
import {Line,Bar} from 'react-chartjs-2';
import styles from './Chart.module.css';
const Chart=()=>{ const[regionData,setRegionData]=useState([]);
const lineChart=( ( <Line data={{ labels: regionData && regionData.map(({region})=>region), datasets:[{ data: regionData&®ionData.map(({totalInfected})=>totalInfected), label:'Infected', borderColor:'#3333ff', fill:true, },{ data: regionData&®ionData.map(({recovered})=>recovered), label:'Recovered', borderColor:'green', fill:true, },{ data: regionData&®ionData.map(({deceased})=>deceased), label:'Deaths', borderColor:'red', fill:true, }], }} />) );
}
export default `Chart;```