Skip to content

Latest commit

 

History

History
43 lines (36 loc) · 2.16 KB

WORKSHOP_BACKEND.md

File metadata and controls

43 lines (36 loc) · 2.16 KB

Workshop: Back-end

Configure nodemon

  • Install it as a dev dependency: npm install --save-dev nodemon

  • Add command for running nodemon in your package.json file:

"dev": "nodemon --watch index.js --watch lib --watch config.js index.js"
  • Usage: npm run dev
  • This will enable us to make changes to the server without having to restart it as it will be done automatically

Add HTTP Requests

By making use of the documentation: HTTP AJAX (15 min)

  • Add an HTTP GET method in index.js to retrieve a mocked JSON with information about your application
  • Use the newly created http method in About.js
  • Method should update your data variable to contain the result of the request
  • Use Debug tools from your browser and check network calls to see if data is received correctly

RemoteData

  • Make use of RemoteData to display information to the user when the requested data is in different states:
    • NotAsked
    • Loading
    • Failure
    • Successful

Web Sockets

  • Add a websocket on the server side, index.js, and bind it to the server
  • Use it to send every 5 seconds a random number as a message under a certain command
  • Make use of WebSocketClient.js and add it to your Model.js;
  • Add a new component in the header of view.js with the random number received via websocket
  • Use DebugTools to watch all numbers sent via webSockets