I'm trying to take input using readline but am running into an unknown error after doing so. To make matters worse, my friend has no difficulties running the exact same piece of code on his device.
const { Octokit } = require("@octokit/rest");
const readline = require("readline");
const util = require('util');
const octokit = new Octokit();
const rl = readline.createInterface(process.stdin, process.stdout);
const question = util.promisify(rl.question).bind(rl);
const getUsername = async () => { return await question("Enter GitHub username: "); }
const getRepoData = async (uname) => { return await octokit.request("/users/" + uname + "/repos"); }
(async () => {
try {
console.log("checkpoint")
const uname = await getUsername();
console.log("checkpoint2")
console.log(uname);
var repoData = await getRepoData(uname);
repoData = repoData["data"]; // is a list of dictionaries, e.g. repoData[0]["name"]
console.log(repoData);
} catch (err) {
console.log("FAILED");
console.log(err);
} finally {
rl.close();
}
})()
My intention is that the program prints out information about a given GitHub user. However, running this program in console with node app.js
results in
checkpoint
Enter GitHub username: fuzzyhappy
FAILED
fuzzyhappy
I have no idea why it's printing back the response to the question either.