我的节点服务器中有以下代码。我遇到间歇性的“套接字不可写”问题,有人知道为什么会这样吗?
第二个问题 - 哪个网格最适合显示我的 json 数据?
var express = require('express');
var app = express.createServer(express.logger());
var pg = require('pg');
var async = require('async');
app.configure(function() {
console.log("Configuring");
app.use(express.bodyParser());
});
app.get('/', function(req, res) {
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Headers", "X-Requested-With");
var output = '';
pg.connect(process.env.DATABASE_URL, function(err, client) {
var query = client.query('SELECT * FROM links');
query.on('row', function(row) {
output += JSON.stringify(row);
});
query.on('end', function() {
client.end();
res.send(output);
});
});
});