Using socket io to get data realtime not working

Using socket io to get data realtime not working

I'm new to mean-stack and I followed some instruction on how to get real-time data. I tried every single steps but none of it is working, how can I use socket.io correctly? I provided my code here for getting users from mongodb, please do correct my code

I'm new to mean-stack and I followed some instruction on how to get real-time data. I tried every single steps but none of it is working, how can I use socket.io correctly? I provided my code here for getting users from mongodb, please do correct my code

server.js

var express     = require ('express');
var app         = express();
var server      = require('http').Server(app);
var http        = require('http').Server(app);
var io          = require('socket.io')(http);
var morgan      = require ('morgan');
var mongoose    = require('mongoose');
var appRoutes   = require('./app/routes/api');

app.use(morgan('dev')); app.use(bodyParser.json()); app.use(bodyParser.urlencoded({ extended: true })); app.use(express.static(__dirname + '/public')); app.use('/api',appRoutes);

mongoose.connect('mongodb://localhost:27017/testing', function(err){ if(err){ console.log('Not connected' + err); } else { console.log('Connected'); } });

Then here is the part where I get the users from the table, I don't know how to get the the data real-time:

api.js

var User = require('../models/user');
const router = express.Router();
router.get('/management', function(req, res) {
        User.find({}, function(err, users) {
                if (!users) {
                    res.json({ success: false, message: 'Users not found' }); 
                } else {
                    res.json({ success: true, users: users,});
                }
        });
    });

userCtrl.js

.controller('managementCtrl', function(User, $scope) {
 function getUsers() { 
        User.getUsers().then(function(data) {
            if (data.data.success) {
                app.users = data.data.users;
} else { app.errorMsg = data.data.message; } }); } });

users.html

<tbody>
    <tr ng-repeat="person in management.users">
        <td align="center">{{ person.name }}</td>
        <td align="center">{{ person.email }}</td>
    </tr>
</tbody>


node-js angular.js express

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

Angular 8 Node & Express JS File Upload

In this Angular 8 and Node.js tutorial, we are going to look at how to upload files on the Node server. To create Angular image upload component, we will be using Angular 8 front-end framework along with ng2-file-upload NPM package; It’s an easy to use Angular directives for uploading the files.

Создание сайта на Mongo DB, Express JS, Node JS и Angular

Видео курс по изучению стека MEAN. В курсе вы научитесь создавать сайты при помощи Node JS, Express JS, Angular JS и баз данных MongoDB. Вы ознакомитесь со всеми моментами разработки и в конце курса выгрузите сайт на удаленный сервер.

How to Use Express.js, Node.js and MongoDB.js

In this post, I will show you how to use Express.js, Node.js and MongoDB.js. We will be creating a very simple Node application, that will allow users to input data that they want to store in a MongoDB database. It will also show all items that have been entered into the database.

How to resumable File Upload in Angular and Node.js

While uploading a large file to server there is a very high chance of internet disconnection so giving a resumable option in upload will be very useful in uploading a large file to the server.

Angular + WebSocket + Node.js Express = RxJS WebSocketSubject ❤️

I this article, you'll learn how to create an Angular client using RxJS WebSocketSubject, WebSocket, Node.js and Express.js