I'm trying to read some input from the repl.it terminal, but the program terminates before the readline interface closes.
I'm currently using code provided directly by node.js. Link to the documentation I'm getting it from is here
Here's all of my code:
const readline = require('readline');
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
rl.question('What do you think of Node.js? ', (answer) => {
// TODO: Log the answer in a database
console.log(`Thank you for your valuable feedback: ${answer}`);
rl.close();
});
Expected result: The question shows up and the program waits for an answer. Then, it logs Thank you for your valuable feedback: <answer-here>
and terminates