title: How is the server and client supposed to interact
body: <p><em>I am just starting out with nodejs backend, so this might be a stupid question.</em></p>
  
  <p><strong>Little info</strong></p>
  
  <p>I got my client (localhost:8080) and my server.js (localhost:3000). I made some routes for my <code>server.js</code> (see the file below). </p>
  
  <p><strong>Question</strong></p>
  
  <p>Now, if I try to access the route on my server e.g. <code>localhost:3000/users/4</code>, I get the expected result - 4 fake users are created. However if I try to append the postfix <code>users/4</code> to the client: (<code>localhost:8080/users/4</code>), I get an error! <code>Cannot GET /users/4</code>. Likewise I get an <code>cannot GET *SOMETHING*</code> if I try one of the other routes. </p>
  
  <p>Have I misinterpreted something? Shouldn't I be able to append the route to the client url and then get the res (respons) back again? (as long as the server is running of course, or is that not how it works?). It would be lovely if someone could clarify how it works. </p>
  
  <p><strong>routes.js</strong> (I got all my routes in this one file)</p>
  
  <pre><code>    var faker = require("faker");
  
  var appRouter = function (app) {
  
  
    app.get("/", function (req, res) {
      res.status(200).send({ message: 'Welcome to our restful API' });
    });
  
    app.get("/user", function (req, res) {
      var data = ({
        firstName: faker.name.firstName(),
        lastName: faker.name.lastName(),
        username: faker.internet.userName(),
        email: faker.internet.email()
      });
      res.status(200).send(data);
    });
  
   app.get("/users/:num", function (req, res) {
     var users = [];
     var num = req.params.num;
  
     if (isFinite(num) &amp;&amp; num  &gt; 0 ) {
       for (i = 0; i &lt;= num-1; i++) {
         users.push({
             firstName: faker.name.firstName(),
             lastName: faker.name.lastName(),
             username: faker.internet.userName(),
             email: faker.internet.email()
          });
       }
  
       res.status(200).send(users);
  
     } else {
       res.status(400).send({ message: 'invalid number supplied' });
     }
  
   });
  };
  
  module.exports = appRouter;
  </code></pre>
  
  <p><strong>Server.js</strong></p>
  
  <pre><code>var express = require("express");
  var bodyParser = require("body-parser");
  var routes = require("./routes/routes.js");
  var app = express();
  
  const server_port = process.env.PORT || 3000;
  
  
  app.use(bodyParser.json());
  app.use(bodyParser.urlencoded({ extended: true }));
  
  routes(app);
  
  var server = app.listen(server_port, function () {
      console.log("app running on port.", server.address().port);
  });
  </code></pre>