Node.js NPM谷歌搜索结果返回[Object Object]作为结果

Node.js NPM Google Search Result Returning [ Object object ] as result

本文关键字:Object 结果 返回 js NPM 谷歌 搜索结果 Node      更新时间:2023-09-26
    gSearch: function(message){
        googleSearch.build({
        q: message                                    
        }, 
        function(error, response) 
        {                     
        console.log(response);
        chain.send('/me ' + response);
        });
    },                  

返回[Object Object]作为结果

这不是HTML,这是一个机器人意味着一个IRC类型的聊天。你发送一个像"搜索词"这样的请求,然后它应该把搜索结果发送回聊天。使用node.js制作

你可以这样写:

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

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

你可能想要stringify它:

console.log(JSON.stringify(response))