노드 서버의 Redis에서 데이터를 가져와 Wordpress 레이아웃으로 보내야합니다. 나는 다음을 시도했다. 그러나 data
는 보내지 않는 것처럼 보인다.Node.js, wordpress, redis
var express = require('express');
var app = express();
var redis = require('redis');
var client = redis.createClient(); //creates a new client
client.on('connect', function() {
console.log('connected');
});
data = [];
client.set(['first', 'Oleh']);
client.set(['second', 'Ivan']);
client.set(['thirt', 'Andriy']);
client.set(['fourth', 'Olena']);
client.set(['fifth', 'Kristy']);
client.set(['sixth', 'Irina']);
client.get('first', function (err, reply) {
console.log(reply);
data.push(reply);
});
client.get('second', function (err, reply) {
console.log(reply);
data.push(reply);
});
client.get('thirt', function (err, reply) {
console.log(reply);
data.push(reply);
});
client.get('fourth', function (err, reply) {
console.log(reply);
data.push(reply);
});
client.get('fifth', function (err, reply) {
console.log(reply);
data.push(reply);
});
client.get('sixth', function (err, reply) {
console.log(reply);
data.push(reply)
});
app.get('http://localhost/wordpress/', function (req, res) {
res.type('application/json'); // set content-type
res.send(this.data); // send text response
console.log(this.data);
});
app.listen(process.env.PORT || 4730);
[지금 가지고있는 것] (http://stackoverflow.com/help/mcve)을 보여줄 수 있습니까? –
질문을 수정하고 거기에 추가하십시오. –