Reputation: 300
I'm using Request module in my nodejs express app, and i need to pass in the querystring any accented character (Ex: josé) but when the other client gets the request it gets an unknown character (?).
If i pass the same url by browser or postman the client gets the correct accent character.
var request = require('request-promise');
var url = 'http://mypathtotheurl?var=josé';
const optionsStart = {
url: url,
method: "GET",
encoding: "binary",
headers: {
"Content-type": "applcation/pdf"
}
};
request(optionsStart).then(function(body, data) {
//my logic working as expected except for show special chars
}
With the browser or postman get the correct response, by request module gets unknow character
Upvotes: 1
Views: 1210
Reputation: 300
I found a quick solution enconding the url in the request method:
var url = 'http://mypathtotheurl?var=josé';
url = encodeURI(url)
Upvotes: 2