Preparing for this chapter
This chapter uses the part2app
project from Chapter 13. The examples in this chapter are easier to understand with a simple command-line client application that sends HTTP requests and displays the responses that are received. To prepare, run the commands shown in Listing 14.1 in the part2app
folder to install the Inquirer
package (https://github.com/SBoudrias/Inquirer.js), which provides features for prompting the user.
Tip
You can download the example project for this chapter – and for all other chapters in this book – from https://github.com/PacktPublishing/Mastering-Node.js-Web-Development. See Chapter 1 for how to get help if you have problems running the examples.
Listing 14.1: Installing a package
npm install @inquirer/prompts@3.3.0
Create the src/cmdline
folder and add to it a file named main.mjs
, with the contents shown in Listing 14.2. The .mjs
file extension tells Node.js to treat this file as...