-1

I want to store the response coming from my socket connection in a global array variable to plot a graph, how can i achieve that

var socket = io('heart sensor api call');
var getValue = function () {
    socket.on('connect', function () {});
    socket.emit('get data', 'hello');
    socket.on('reply', function (data) {
        heart_rate = data;

    });
}

1 Answers1

0

If you are using express. You could create global.heart_rate = ... it will create a global variable accessible from every where. As this is not recommended, I would suggest looking in to app.locals. Hope this helps.

vredrav
  • 21
  • 3