title: Updating data realtime in Node.js express website
body: <p>I'm trying to achieve something what I think should be very simple to do, but all the tutorials and examples I find seem to be an overkill.</p>
  
  <p>What I am doing:
  I'm fetching weather info periodically, and I want to update the text on the website everytime its fetched without user having to refresh the browser.</p>
  
  <p>Almost every tutorial on realtime data updating recommends using socket.io and I have given it a try, but I can't get it to do what I want and I'm starting to think that there should be an easier way and that socket.io might not be the best way to go about this. Any suggestions? How do I get simple line of text update on website without user having to refresh the page?</p>
  
  <p>My weather script:</p>
  
  <pre><code>var express = require('express');
  var app = express();
  var server = require('http').Server(app);
  var io = require('socket.io')(server);
  
  
  function refreshWeather() {
      var temperature = getTemperature();
      io.sockets.emit('broadcast', {
          temperature : temperature
      });
  }
  </code></pre>
  
  <p>My jade script:</p>
  
  <pre><code>doctype html
  html
    head
      link(rel='stylesheet', href='/css/index.css')
      title Dashboard
    body
      script(src='/socket.io/socket.io.js')
      script.
        var socket = io();
        socket.on('broadcast', function (data) {
        // UPDATE WEATHER HERE
        });
  
      .main-content
        h1 Weather is: // I WANT THIS TO BE UPDATED
  </code></pre>