I'm working on a school assignment, Node.js, and have trouble with getting my output correct. It's the res.end part that isn't working, but res.end(stdout); works. Why?
case "/status":
/**
* Run child process "uname -a".
*/
cp.exec("uname -a", (error, stdout, stderr) => {
if (error || stderr) {
// Do something with the error(s)
console.log("Something went wrong...", error, stderr);
}
// status route
res.writeHead(200, { "Content-Type": "application/json" });
res.end({
"uname": stdout
});
});
break;