Node.js NPM Google搜索结果返回[Object object]作为结果

时间:2016-08-23 15:21:42

标签: javascript node.js npm

    gSearch: function(message){
        googleSearch.build({
        q: message                                    
        }, 
        function(error, response) 
        {                     
        console.log(response);
        chain.send('/me ' + response);
        });
    },                  

返回[Object object]作为结果

这不适用于HTML,它是一个用于IRC类型聊天的机器人。您发送了一个请求,例如!g“搜索字词”,然后它应该将搜索结果发送回聊天。用node.js制作

2 个答案:

答案 0 :(得分:0)

你可以做出类似的事情:

gSearch: function(message){ googleSearch.build({ q: message
}, function(error, response) {
console.log(response); chain.send('/me', JSON.stringify(response)); }); },

答案 1 :(得分:0)

[Object object]是javascript对象的序列化。

您可能需要stringify

console.log(JSON.stringify(response))