我收到此错误"无法读取null"的属性RDF对于这部分代码

时间:2015-08-01 16:53:23

标签: node.js

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;
&#13;
&#13;

});

1 个答案:

答案 0 :(得分:0)

错误本身很容易诊断;返回的 body.query.results 为空。看一下请求功能,找出为什么 body.query 没有您要查找的结果属性。