Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

209
Views
How to emit data from NodeJS API call to Front-End with SocketsIO

I've made Electron app which uses Socket.IO to communicate between back-end (NodeJS) and front-end (Jquery).

I've already sent data from

io.on('connection', (socket) => { socket.emit (.....) })

My problem is that I am not able to send data from API call.

Let me tell you the example.

const express = require('express')
const app = express()
const http = require('http')
const server = http.createServer(app)
const { Server } = require("socket.io");
const io = new Server(server);

app.set('socketIo', io);

app.get('/api/run', (req, res) => {
    const ioEmitter = req.app.get("socketIo");
    ioEmitter.emit('data', 'some data'); // not working
    // ioEmitter.to(~some socket id~).emit('data', 'some-data')
    // not working either. I can't get anything to client side
})

Client side code

socket.on('data', (msg) => {
    console.log(msg)
})

It's mandatory for me (the project) to get that data from API call.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!