Advanced Node and Express - Announce New Users issue

Good evening Guys,
I am stuck at announcing new Users lesson I have pursued the steps one by one but seems that always give me that error message:
You should change the text of #num-users within on your client within the "user" even listener to show the current users connected
basically here it asks me to use JQuery to show number of users online when firing users event I did as it was requested but once I hit submit button it show me that error message
here is my server.js code:

'use strict';

const express     = require('express');
const session     = require('express-session');
const bodyParser  = require('body-parser');
const fccTesting  = require('./freeCodeCamp/fcctesting.js');
const auth        = require('./app/auth.js');
const routes      = require('./app/routes.js');
const mongo       = require('mongodb').MongoClient;
const passport    = require('passport');
const cookieParser= require('cookie-parser')
const app         = express();
const http        = require('http').Server(app);
const sessionStore= new session.MemoryStore();
const io = require("")(http);
const passportSocketIo = require("passport.socketio");
const cors = require("cors");

fccTesting(app); //For FCC testing purposes

app.use('/public', express.static(process.cwd() + '/public'));
app.use(bodyParser.urlencoded({ extended: true }));
app.set('view engine', 'pug')

  secret: process.env.SESSION_SECRET,
  resave: true,
  saveUninitialized: true,
  key: 'express.sid',
  store: sessionStore,

mongo.connect(process.env.DATABASE, (err, db) => {
    if(err) console.log('Database error: ' + err);
    auth(app, db);
    routes(app, db);
          var currentUsers = 0;

    http.listen(process.env.PORT || 3000);

  cookieParser: cookieParser,
    key: "express.sid",
    secret: process.env.SESSION_SECRET,
    store: sessionStore,
    success: onAuthorizeSuccess,
    fail: onAuthorizeFail
  function onAuthorizeSuccess(data, accept) {
    console.log("Success connection to");
    accept(null, true);
  function onAuthorizeFail(data, message, error, accept) {
      throw new Error(message);
    console.log("failed connection to web socket", message);
    accept(null, true);
      accept(new Error(message));
    //start code  
io.on("connection", function(socket) {
    console.log('user ' + +' connected');

  socket.on("disconnect", (socket) => {

  socket.on('user', function(data) {
    $('#{num-users}').text(data.currentUsers+ " users online");
    var message =;
    if(data.connected) {
     message += " has joined the chat.";
    } else {
      message += " has left the chat.";
        $('#messages').append($('<li>').html('<b>' + message + '<\/b>'));


      io.emit('user', {name:, currentUsers, connected: true});


    //end code

here is my client.js code:

$( document ).ready(function() {
  /*global io*/
var socket = io();  
   socket.on("user count", function(data) {



  // Form submittion with new message in field with id 'm'
    var messageToSend = $('#m').val();
    //send message to server here?
    return false; // prevent form submit from refreshing page

here is my chat.pug code:

    title FCC Advanced Node and Express
    meta(name='description', content='Home page')
    link#favicon(rel='icon', href='', type='image/x-icon')
    meta(http-equiv='X-UA-Compatible', content='IE=edge')
    meta(name='viewport', content='width=device-width, initial-scale=1')
    link(rel='stylesheet', href='/public/style.css')
  body FCC Advanced Node and Express Socket.IO Chat Room
          button Send
      a#logout(href='/logout') Logout  
    script(src='', integrity='sha256-gvQgAFzTH6trSrAWoH1iPo9Xc96QxSZ3feW6kem+O00=', crossorigin='anonymous')

Thank you in dvance

Did you figure it out? All I can see is that your
socket.on(‘user’, … statement should be moved to the client.js file.

I just spent 2-3 hours trying to figure out why I couldn’t pass the other test for this and the following challenge.

Event ‘user’ is emitted with name, currentUsers, and connected

Turns out the test wants things formatted in a particular way. Using line breaks for read-ability fails all day long:

io.emit('user', {
  currentUsers: currentUsers, 
  connected: true

All crammed together passes the test.

io.emit('user', {name:, currentUsers: currentUsers, connected: true});

Same object.


Thank you so much I have passed it long time ago :slight_smile: