I just started learning Node.js.
I am trying to return the body of the response by using node-fetch but I received an undefined output. I should get a '0' as response but I am getting '200 undefined'
this is from the target website where I am trying to get '0'
<td id="pendingBlocks" style="text-align:center;vertical-align: middle;">0</td>
this is the script.
const fetch = require("node-fetch");
async function getCourseCode() {
try {
let response = await fetch('https://websitehere');
let body = await response.text();
console.log(response.status);
//console.log(body);
let responseBody = body.match("pendingBlocks");
let pending = responseBody[1];
console.log(pending);
}
catch(exception){
console.log(exception);
}
}
getCourseCode();