Skip to content

Tag: node-fetch

How to get a certain element from a body?

I use node-fetch , and I get the body of the site this way: The console displays the full body of the entire page. But I want to get a specific element with a certain class. How do I change the code to do this? Answer You can use cheerio.js. It is an implementation of jQuery for node. The below

Catch block not working in node fetch

Trying to learn, Javascript. Pardon if this is really a basic thin i am missing. I am trying to run node-fetch to a wrong url, and i expect that it should be catched and log my appropriate message. However when i run this file through node, it gives me uncatched error Answer Its this part that is uncatched: T…