当前位置: 动力学知识库 > 问答 > 编程问答 >

node.js - I got this error "Cannot read property RDF of null" for this part of code

问题描述:

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 sideres.send(craig);});

});

网友答案:

The error itself is easy to diagnose; the body.query.results returned is null. Take a look at the request function and figure out why the body.query doesn't have the results property you're looking for.

分享给朋友:
您可能感兴趣的文章:
随机阅读: