C
C
cyberboyx2020-01-09 21:55:22
JSON
cyberboyx, 2020-01-09 21:55:22

For some reason the b function is empty, because of this json.parse() gets an empty response, but I don't understand why?

const rq2 = require("request")
  rq2.get("http://api.openweathermap.org/data/2.5/weather?q="+encodeURIComponent(message.$match[1])+"&lang=ru&units=metric&appid=5d8820e4be0b3f1818880ef51406c9ee", function (e,r,b){
                var data = JSON.parse(b);
                if(!data.name) return message.reply("❌ Прости, но такой город не найден.. ");
                message.reply(data.name+" | "+data.sys.country+"\nПогода: "+data['weather'][0]['description']+"\nВетер: "+data.wind.speed+" m/s "+data.wind.deg+"°"+"\nТемпература: "+data.main.temp+"°C"+"\n☁Облачность: "+data.clouds.all+"%\nДавление: "+data.main.pressure);
        });

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question