我在Node js中使用Request来调用Google Place api Web服务.请求正文出错,Invalid request. One of the input parameters contains a non-UTF-8 string.因为我在url参数(keyword参数)中使用高棉字符.
nearByUrl = 'https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=11.55082623,104.93225202&radius=400&keyword=????????????&key=' + MY_KEY;
request({
url: nearByUrl,
json: true
}, function (error, response, body) {
console.log(JSON.stringify(body, null, 2));
})
Run Code Online (Sandbox Code Playgroud)
但是,当使用Chrome浏览器中的高棉字符调用完全相同的URL时,我可以获得有效的JSON结果.
这个问题与Request有关吗?
我怎样才能解决这个问题?