JavaScript Programming/Node.js REST API
This lesson introduces Node.js, Express.js and REST APIs.
Objectives and Skills
editObjectives 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
editMultimedia
editExamples
editActivities
edit- Install Node.js
- Review Medium: Building a simple REST API with NodeJS and Express.
- Download and install Node.js
- Use a command prompt or terminal window to verify Node.js installation:
node -v
npm -v
- 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
- Create a new folder for your REST server application. In that folder, run the following command to generate an Express.js template:
- Create a simple REST API
- Copy the REST API example code to create a REST API website.
- Start the website using the command:
node server.js
- Revise your JavaScript Programming/AJAX and JSON project to send data to your Express.js server.
Lesson Summary
edit- Bullet points
Key Terms
edit- term
- definition