request(url, function(err, resp, body) {
request(url, function(err, resp, body) {
body = JSON.parse(body);
// logic used to compare search results with the input from user
// console.log(!body.query.results.RDF.item['about'])
if (!body.query.results.RDF.item) {
craig = "No results found. Try again.";
} else {
results = body.query.results.RDF.item[0]['about']
craig = '<a href ="'+results+'">'+results+'</a>'
}
// pass back the results to client side
res.send(craig);
});
});
&#13;
});
答案 0 :(得分:0)
错误本身很容易诊断;返回的 body.query.results 为空。看一下请求功能,找出为什么 body.query 没有您要查找的结果属性。