我正在开发一个前端的应用程序,因为角度和后端是节点js,从数据库列出一些值并发送到节点js。它显示一些错误,如循环结构是否有任何方式可以覆盖或任何其他选项来响应发回给我的客户端。
节点js服务器实例是:
app.post('/countrylist', function(req, res) {
var urlMataData = {
request : req,
responce:res
};
amqHandler.sendToAMQPServer(serialize.serialize(urlMataData),amqpConnection, 'countrylist' ,function(err,result){
console.log("callback value==>" + result)
});
amqHandler.reciveData(amqpConnection,'countrylist' ,function(err,data){
if(!err ){
console.log("am reciving request")
httpRequestHandler. makeHttpRequest(data,'countrylist', function(row){
console.log("CountryType==>"+ JSON.parse( row));
//res.json(row);
});
} else {
res.json(err);
}
});
});
请求处理程序是:
var countryList = function(req, res, next) {
query = 'SELECT id_country, country FROM edu.tbl_country';
database.getConnection(function (err, con) {
if(!err){
con.query(query, function(err,row) {
console.log("row type:"+ typeof row );
//res.contentType('application/json');
res.json(JSON.stringify(row));
});
}
});
};
错误
var body = JSON.stringify(val, replacer, spaces);
^
TypeError: Converting circular structure to JSON
at Object.stringify (native)
at ServerResponse.json (/root/nodejsworkspace/EDU/rabitmq/node_modules/express/lib/response.js:228:19)
at ClientRequest.<anonymous> (/root/nodejsworkspace/EDU/rabitmq/AMQPServer.js:116:23)
at ClientRequest.g (events.js:273:16)
at emitOne (events.js:90:13)
at ClientRequest.emit (events.js:182:7)
at HTTPParser.parserOnIncomingClient [as onIncoming] (_http_client.js:469:21)
at HTTPParser.parserOnHeadersComplete (_http_common.js:103:23)
at Socket.socketOnData (_http_client.js:359:20)
at emitOne (events.js:90:13)