UNPKG

node-desleri-by105

Version:

du bir deneme sürümüdür. 22222

32 lines (24 loc) 1.33 kB
const axios = require("axios"); const capitalWeather= require("./capital_weather"); function findCapitalWeather(countryName){ axios.get("https://restcountries.eu/rest/v2/name/"+countryName, {}) .then(response => { /* console.log(response.data[0].translations.de) console.log(response.data[0].borders[3]) console.log(response.data[0].population) */ const country = response.data[0]; const capital = country.capital; const population = country.population; const enlem = country.latlng[0]; const boylam = country.latlng[1]; console.log(`Başkent: ${capital} Nufus: ${population} Enlem : ${enlem} Boylam: ${boylam}`) axios.get("http://api.openweathermap.org/data/2.5/weather?q=" + capital + "&appid=12cd77181c6cfa17c3441cb0c8f48fb4&lang=tr&units=metric") .then(response => { //console.log(response.data) console.log(`Başkent :${response.data.name} bugün hava : ${response.data.weather[0].description} ve Sıcaklık: ${response.data.main.temp}`) } ) }) .catch(err => console.log("hata çıktı => " + err)) } module.exports=findCapitalWeather;