所以我有这个server.js,但是我尝试了每种解决方案都可以运行到socket.io,但是当我从mongodb中插入值时,它并不能实时显示
var express = require ('express');
var app = express();
var port = process.env.PORT || 8080;
app.listen(port, function(){
console.log('Running the server on port ' + port);
});
我尝试了此操作,但不起作用
var express = require ('express');
var app = express();
var port = process.env.PORT || 8080;
var io = require("socket.io")(port);
app.listen(io, function(){
console.log('Running the server on port ' + port);
});