adrianhajdin/project_corona_tracker

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

Phimanshu07 opened this issue · 3 comments

after selecting countries from option I am getting this error

chrc commented

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

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);

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