小编sac*_*hin的帖子

在Socket.io中,如何获取存储的cookie信息?

在使用express的节点应用程序中,我存储了cookie信息.现在我需要在socket.io中获取存储的cookie信息.我怎么能得到这个?

    app.use(function (req, res, next) {

        res.cookie('cookieName','1', { maxAge: 50000, httpOnly: true });
    });

    io.sockets.on('connection', function (socket) {

     //here i need to access the cookie.how can i do this

    });
Run Code Online (Sandbox Code Playgroud)

cookies node.js express

2
推荐指数
1
解决办法
2696
查看次数

在node.js中,如何在处理uncaughtException中的异常时重新启动服务器

在我的应用程序中我使用uncaughtException来处理应用程序错误.在这个如何重新启动服务器.

node.js uncaught-exception

1
推荐指数
1
解决办法
1283
查看次数

如何在postgresql中创建和存储对象数组

在postgresql允许的数组类型或整数和text.But我需要创建对象数组.我可以这样做.

myarray text[];   //for text ['a','b','c']
myarray integer[];  //for integer[1,2,3]
Run Code Online (Sandbox Code Playgroud)

我需要创建如下所示的数组

[{'dsad':1},{'sdsad':34.6},{'sdsad':23}] 
Run Code Online (Sandbox Code Playgroud)

我不想使用JSON类型.使用数组类型我需要存储对象数组.

postgresql

1
推荐指数
2
解决办法
1万
查看次数

In redis how to get the value of the particular key?

In my node application i'm using redis DB to store the data.While getting the stored value using key i'm not getting the expected output.

var redis=require('redis');
var client = redis.createClient();
var pageContent={a: "a", b: "b", c: "c"};
//client.set('A',pageContent);//here i'm setting the value
client.get('A',function(err,res){
 if(!err){
   Object.keys(res).forEach(function(k){
     console.log('key is '+k + ' value is '+res[k]);
    });
   }
 else{
    console.log('error');
   }
 });
Run Code Online (Sandbox Code Playgroud)

Above code is not giving the stored value.While looping the result i'm getting the below error

 TypeError: Object.keys called on non-object …
Run Code Online (Sandbox Code Playgroud)

redis node.js

0
推荐指数
1
解决办法
5960
查看次数

如何在Node.js中获取发布数据?

Server1.js

var data = querystring.stringify({
    imageName: reqImgName
  });

var options = {
              host: 'localhost',
              port: 4321,
              path: '/image',
              method: 'POST',
              headers: {
                    'Content-Type': 'application/x-www-form-urlencoded',
                    'Content-Length': data.length
                }
            };
Run Code Online (Sandbox Code Playgroud)

server2.js

http.createServer(function(req, res){
  var reqMethod=req.method;
  var request = url.parse(req.url, true);
  var pathName = request.pathname;
  console.log('Path name is '+pathName);
  if (reqMethod=='POST' && pathName == '/image') {

   //here i need my server1 data..how can i get here.
   } 

}).listen(4321);
Run Code Online (Sandbox Code Playgroud)

node.js

0
推荐指数
1
解决办法
3021
查看次数