Skip to content

What does app.set('socketio', io) do? #4157

Answered by darrachequesne
oshihirii asked this question in Q&A
Discussion options

You must be logged in to vote

app.set('socketio', io) stores the Socket.IO server so you can retrieve it later with app.get('socketio'). For example:

app.post('/hello', (req, res) => {
  app.get('socketio').emit('hello');
  res.send('done');
})

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Answer selected by darrachequesne
Comment options

You must be logged in to vote
1 reply
@darrachequesne
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants