adrianhajdin / project_corona_tracker

This is a code repository for the corresponding YouTube video. In this tutorial, we are going to build and deploy a corona tracker application. Covered topics: React.js, Chart.js, Material UI, and much more.
https://covid19statswebsite.netlify.com/
1.45k stars 476 forks source link

xhr.js:184 GET http://localhost:3000/$%7Burl%7D/countries/$%7Bcountry%7D 404 (Not Found) #24

Open Phimanshu07 opened 3 years ago

Phimanshu07 commented 3 years ago

after selecting countries from option I am getting this error

chrc commented 3 years ago

Could you share your src/api/index.js?

Phimanshu07 commented 3 years ago

import axios from 'axios';

const url = 'https://covid19.mathdro.id/api';

export const fetchData= async (Country)=>{ let changeableurl=url; if(Country){ changeableurl='${url}/countries/${Country}' } try { const { data: {confirmed,recovered,deaths,lastUpdate}}=await axios.get(changeableurl);

      return {confirmed,recovered,deaths,lastUpdate}
} catch (error) {
    return error;
}

}

export const fetchDailyData = async () =>{ try { const {data} = await axios.get(${url}/daily); console.log(data); const modifiedData=data.map((dailyData)=>({ confirmed: dailyData.confirmed.total, deaths: dailyData.deaths.total, date: dailyData.reportDate, })); return modifiedData; } catch (error) { return error; } }

export const fetchcountries = async () =>{ try { const {data:{countries}}= await axios.get('https://covid19.mathdro.id/api/countries') //console.log(response) return countries.map((country) =>country.name) } catch (error) { return error; } } fetchcountries().then(console.log);

Phimanshu07 commented 3 years ago

Could you share your src/api/index.js?

if i select any country from country picker then data of country is showing .I think is this error ? pls help fast