Answer the question
In order to leave comments, you need to log in
How to solve the error about sending a get request?
An error occurs when sending a request
TypeError [ERR_UNESCAPED_CHARACTERS]: Request path contains unescaped characters
var http = require('http');
http.get(`http://api.openweathermap.org/data/2.5/weather?q=${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)
}
Answer the question
In order to leave comments, you need to log in
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)
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question