JavaScript Programming/Node.js REST API

From Wikiversity
Jump to navigation Jump to search

This lesson introduces Node.js, Express.js and REST APIs.

Objectives and Skills[edit | edit source]

Objectives and skills for this lesson include:

  • Understand Node.js concepts
  • Understand Express.js concepts
  • Use Node.js and Express.js to implement a simple REST API

Readings[edit | edit source]

  1. Wikipedia: Node.js
  2. Wikipedia: Express.js
  3. Wikipedia: REST API

Multimedia[edit | edit source]

Examples[edit | edit source]

Activities[edit | edit source]

  1. Install Node.js
  2. Configure and test Express.js
    • Create a new folder for your REST server application. In that folder, run the following command to generate an Express.js template:
          npm install express-generator
    • Install Express and CORS using the following commands:
          npm install express --save
          npm install cors --save
    • Copy the Hello World example code to create a simple Express.js website.
    • Start the website using the command:
          node server.js
    • Test your server by using your web browser to navigate to:
          http://localhost:3000
  3. Create a simple REST API

Lesson Summary[edit | edit source]

  • Bullet points

Key Terms[edit | edit source]

term
definition

See Also[edit | edit source]

References[edit | edit source]