Node.js
- 2 ответа
- 0 вопросов
2
Вклад в тег
var http = require('http');
http.get(`http://api.openweathermap.org/data/2.5/weather?q=${encodeURIComponent(city)}?lang=ru?units=metric&APPID=My_API_Key`, function(resp){
var body = ''
resp.on('data', function(data){
body += data;
});
resp.on('end', function(){
var json = JSON.parse(body);
console.log(body)
}
let valute = {
AMD: {ID: 'R01060', NumCode: '051', CharCode: 'AMD', Nominal: 100, Name: 'Армянских драмов', Value: 13.7825},
AUD: {ID: 'R01010', NumCode: '036', CharCode: 'AUD', Nominal: 1, Name: 'Австралийский доллар', Value: 13.7825}
};
let string = '';
for (let [key, _value] of Object.entries(valute)) {
string += `${key}:\n`;
for (let [prop, value] of Object.entries(_value)) {
string += `${prop}: ${value}\n`;
}
string += '\n';
}
console.log(string);
const someIDs = [1, 2, 3];
const users = someIDs.map(async(ID) => {
const user = await getUser(ID);
return user;
});
cosnole.log(users);
(async() => {
const someIDs = [1, 2, 3];
const users = [];
for (const ID of someIDs) {
const user = await getUser(ID);
users.push(user);
}
console.log(users);
})();