Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Phimanshu07 opened this issue Oct 22, 2020 · 3 comments

Comments

@Phimanshu07
Copy link

after selecting countries from option I am getting this error

@chrc
Copy link

chrc commented Oct 28, 2020

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

@Phimanshu07
Copy link
Author

Phimanshu07 commented Oct 29, 2020

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
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants