Java Script Fetch Returns 200 But No Data
I have a requirement to display all the countries in the world in a drop down. So I found this api end point END POINT LINK. When I copy and paste this end point link in my web bro
Solution 1:
You can use as follow:
let url = 'https://restcountries.eu/rest/v1/all';
fetch(url)
.then(res => res.json())
.then((data) => {
console.log(data);
})
.catch(err => { throw err });
Solution 2:
This works for me
functiongetCountries(){
fetch("https://api.printful.com/countries ")
.then((resp) => resp.json()) // Transform the data into json
.then(function(data) {
let countries = data.result;
return countries.map(function(country){
console.log(country.name);
//Create your list here
});
});
}
Solution 3:
responce.type 'cors' probably means Cross Origin Request - and it's blocking it - try to find another api
Post a Comment for "Java Script Fetch Returns 200 But No Data"