I'm struggling to retrieve information from the restcountries.eu API using a promise.all
method, and I am having difficulty identifying the issue.
function displayCurrency(currencyone, currencytwo) {
Promise.all([
fetch(`https://restcountries.eu/rest/v2/currency/${currencyone}`),
fetch(`https://restcountries.eu/rest/v2/currency/${currencytwo}`)
])
.then(function (responses) {
return responses.map(function (response) {
return response.json();
});
}).then(function (data) {
console.log(data[0]);
}).catch(function (error) {
console.log(error);
});
}
data[0]
returns a resolved promise containing an array. Despite my attempts to access data within the array like 'name' and 'currencies', all I receive is undefined values.