在使用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) 在我的应用程序中我使用uncaughtException来处理应用程序错误.在这个如何重新启动服务器.
在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类型.使用数组类型我需要存储对象数组.
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) 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)