-
Notifications
You must be signed in to change notification settings - Fork 0
/
getCountriesInfo.js
29 lines (20 loc) · 967 Bytes
/
getCountriesInfo.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
const User = require("../models/user");
const bodyParser = require('body-parser');
const fetch = require("node-fetch");
const apiRoute11 = "https://restcountries.eu/rest/v2/alpha/"
let visitedCountries = [];
let responses = [];
User.findById(req.params.id, function(err, foundUser) {
visitedCountries=foundUser.countriesVisited;
})
for (let i=0;i<visitedCountries.length;i++) {
async function getAllCountriesInfo (visitedCountries) {
const response = await fetch( `${apiRoute11} + visitedCountries[i]` )
responses.push(response) ;
console.log(responses)
return (await response.json()).results
}
}
module.exports = {
responses
}