【发布时间】:2011-09-12 11:09:06
【问题描述】:
searchJSON = {
location: 'NYC',
text: text,
authID: apiKey
};
searchRequest = {
host: siteUrl,
port: 80,
path: '/search',
method: 'GET'
};
searchResponse = makeRequest(searchRequest, searchJSON);
makeRequest = function(options, data) {
var req;
if (typeof data !== 'string') {
data = JSON.stringify(data);
}
req = http.get(options, function(res) {
var body;
body = '';
res.on('data', function(chunk) {
body += chunk;
});
return res.on('end', function() {
console.log(body);
});
});
console.log(data);
req.write(data);
req.end();
};
这不应该翻译成http://www.somesite.com/search?location=NYC&text=text&authID=[mykey]吗?
【问题讨论】:
-
看起来您正在尝试执行 GET,但正在写入消息正文。