Core ModulesLesson 21Free preview
HTTP Module
This lesson is part of Node.js · All levels
Summary
The Node's built-in HTTP module allows you to create HTTP servers without an additional framework. You create a server with createServer, and then you handle every request and response in the callback. This module can also be used as a client to send requests to other services.
Key points
- Http.createServer(callback) creates servers with req and res access
- The server starts listening to the port with server.listen(port)
- Set the correct response: statusCode, header Content-Type, then body
- Http.get or http.request are used to send out requests
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.