I am using Promise to log the response from an api. But everytime the body is logging in as null. Most probably due to async call
For calling api from fetch.
function getDetails(url){
return new Promise((resolve, reject) => {
fetch(url, {mode: 'no-cors'}).then(res => {
resolve(res);
}, error => {
console.log(err);
})
})
}
var u = "https://get.geojs.io/v1/ip/country.json";
getDetails(u).then(function(resp){
console.log(resp);
})
I expect the response of the api in console