Created
July 10, 2017 23:28
-
-
Save muratgozel/a2568659ed8ab530ac288c7417b94d3d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const redis = require('redis') | |
// Create a standart redis client which will be subscriber in our case. | |
const sub = redis.createClient() | |
// Attach a listener to receive new messages as soon as subscribe to a channel. | |
sub.on('message', function(channel, message) { | |
// message is json string in our case so we are going to parse it. | |
try { | |
const json = JSON.parse(message) | |
// json.csrfToken is our csrfToken we have created in our frontend server! | |
} catch (e) { | |
// This error indicates that we receive a message that is not in the json format. | |
} | |
}) | |
// Subscribe to a channel and start handling messages | |
sub.subscribe('parameter-mapping') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment