Creating a weather app using node.js and the OpenWeatherMap API

let request = require('request');let apiKey = '34ef108283d61ecbca72455a49a8d6b2';let cidade = 'Guarda';let url = `http://api.openweathermap.org/data/2.5/weather?q=${cidade}&appid=${apiKey}&units=metric`request(url, function (err, response, body) {if(err){console.log('error:', error);} else {let weather = JSON.parse(body);let dados = `DADOS METEROLÓGICO PARA a ${weather.name}:------------- Temperatura (ºC): ${weather.main.feels_like}- Humidade: ${weather.main.humidity}- Visibilidade: ${weather.visibility}- Vento (km/h): ${weather.wind.speed}`console.log(dados);}});
node index.js

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Afonso Antunes

Afonso Antunes

Finalist student in Computer Engineering