What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Some links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.
In Node.js, call the global fetch() function, check the returned response’s status, and read its body with response.text(). This retrieves the server’s HTTP response without opening a browser. It does not render the page or run its client-side JavaScript, and it does not guarantee access to every URL: authentication, network restrictions, and other server controls may still apply.
What Fetch does—and what it doesn’t
Fetch is a JavaScript API for making HTTP requests and processing their responses. A call such as fetch(url) returns a Promise that resolves to a Response object. You can inspect its status and headers, then read the response body as text, JSON, or another supported format. MDN describes Fetch as an interface for making HTTP requests and processing responses (MDN Fetch API).
That makes Fetch useful for retrieving the HTML a server sends, but it is not a browser. It does not lay out a page, display images, or run scripts that fetch and insert more content after the initial response. If a page depends on client-side JavaScript to show the information you need, a plain Fetch request may return only the initial HTML shell. Parsing HTML or executing its scripts is a separate task.
The Tool Desk
Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →The word “any” needs a qualification: a Node.js process can make server-side requests without the browser’s CORS response-sharing restriction, but Fetch is not a way around authentication, bot checks, rate limits, network access rules, or a site’s terms. In browser JavaScript, cross-origin access is explicitly restricted by CORS.
#1 Best Overall
Read a webpage with Node.js
Node.js includes a browser-compatible global fetch() based on Undici. The Node.js v22.23.3 documentation records support added in v17.5.0 and v16.15.0, and says Fetch became stable in v21.0.0 (Node.js global objects documentation). Check your installed runtime with node --version; if you use an older release, the global may be unavailable or experimental.
Runnable example: save the returned HTML
Save this as fetch-page.mjs, then run node fetch-page.mjs https://example.com. Replace the URL with a page you are permitted to retrieve.
const url = process.argv[2];
if (!url) {
console.error("Usage: node fetch-page.mjs <url>");
process.exitCode = 1;
} else {
try {
const response = await fetch(url);
if (!response.ok) {
throw new Error(`HTTP ${response.status} ${response.statusText}`);
}
const html = await response.text();
console.log(html);
} catch (error) {
console.error("Could not retrieve the page:", error.message);
process.exitCode = 1;
}
}
The example uses top-level await, which works in an .mjs file. In a CommonJS .js file, put the asynchronous code inside an async function and call it.
Why check response.ok?
A resolved Fetch Promise is not proof that the request succeeded. HTTP statuses such as 404 still produce a Response; the program must test response.ok or inspect response.status before treating the body as a successful result. By contrast, a network-level failure can reject the Promise and enter the catch block. MDN explains this distinction in its Using the Fetch API guide.
Rank #2
- HTML CSS Design and Build Web Sites
- Comes with secure packaging
- It can be a gift option
Read JSON instead of HTML
If the URL returns JSON, use response.json() rather than response.text(). Check the status first in the same way:
const response = await fetch("https://example.com/data.json");
if (!response.ok) {
throw new Error(`HTTP ${response.status}`);
}
const data = await response.json();
console.log(data);
Calling json() parses the body as JSON; it does not make an HTML page into structured data. To inspect HTML, read it as text and use a separate HTML parser if you need to query its elements.
Use Fetch in a browser
Fetch is available in browser Window and Worker contexts. A same-origin request can generally be read by the page’s script, subject to the browser’s normal security rules. For a cross-origin URL, the destination server must opt in to sharing the response by sending appropriate CORS headers. The browser enforces this policy; changing JavaScript code on your page cannot grant itself permission to read another site’s response. See the WHATWG Fetch Standard and MDN’s Fetch guide.
Example: read a same-origin response
async function loadPageText() {
const response = await fetch("/content/page.html");
if (!response.ok) {
throw new Error(`HTTP ${response.status}`);
}
return await response.text();
}
loadPageText()
.then((html) => console.log(html))
.catch((error) => console.error(error));
For a cross-origin request, the same code works only if the other server allows your page’s origin. If it does not, the browser will not expose the response body to the script. A server-side endpoint you control can sometimes make a request on the browser’s behalf, but that endpoint must be designed with access controls and the destination’s rules in mind; it should not be an unrestricted proxy.
Rank #3
Why mode: "no-cors" does not solve it
no-cors is not a way to read a blocked cross-origin page. It yields an opaque response: JavaScript cannot inspect its body or headers. If you need to read text or status details, the destination must permit the request through CORS, or you need a legitimate server-side approach. MDN documents the opaque-response limitation in Using the Fetch API.
Browser Fetch and Node.js Fetch compared
| Question | Browser JavaScript | Node.js |
|---|---|---|
| Where it runs | Window or Worker context, as documented by MDN. | Server-side JavaScript using Node.js’s global, browser-compatible implementation based on Undici. |
| Can it read a cross-origin response? | Only when the target server permits response sharing through CORS. A no-cors response is opaque. | It is not subject to the browser’s CORS response-sharing mechanism. This does not imply access to browser sessions or permission to retrieve protected content. |
| Can it render the page? | No. Fetch retrieves a resource; rendering is the browser’s separate job. | No. Fetch retrieves a resource; it does not execute the page as a browser. |
| Version detail | Browser support depends on the browser environment; no version threshold is established by the cited sources here. | Node.js v22.23.3 documentation records additions in v17.5.0 and v16.15.0 and stable status from v21.0.0. |
When you need the rendered page rather than its HTML
If your goal is to see the page as a visitor sees it—including layout and content produced after scripts run—you need a browser-rendering tool, not just Fetch. For a one-off local task, opening a browser is the direct option. For an automated capture, ScreenshotNeo is a website screenshot API and MCP server for developers: it returns a screenshot or PDF, rather than the raw response text. Learn more at ScreenshotNeo.
Or skip the browser setup
If you need a rendered capture instead of raw HTML, make a single GET request with the page URL. The code below saves the response as an image; available output formats include PNG, JPEG, WebP, and PDF. See the ScreenshotNeo API documentation for request options.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
ScreenshotNeo accepts cookie or consent banners as a visitor and removes more than 60 known consent platforms, newsletter popups, and chat widgets before capture; each step can be turned off. Only clean shots are billed: bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits cost nothing, with the response indicating the page verdict and billing status in headers. Its MCP server provides screenshot and page-information tools for AI-agent clients. The free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 shots.
Sign up free for 1,000 screenshots a month—no card required.
Rank #4
- Brand: Wiley
- Set of 2 Volumes
- A handy two-book set that uniquely combines related technologies Highly visual format and accessible language makes these books highly effective learning tools Perfect for beginning web designers and front-end developers
Troubleshooting Fetch requests
The script prints an error for a 404 or 500
Fetch normally resolves with a response for HTTP error statuses; it does not automatically throw just because the status is unsuccessful. Check response.ok and report response.status before parsing or using the body. A server may return useful error details in that body, so read it deliberately when diagnosing the endpoint.
The browser reports a CORS error
The destination has not permitted your page’s origin to read the response, or the request did not satisfy the server’s CORS policy. Ask the destination to configure CORS if you control it, use an allowed API endpoint, or make a controlled server-side request where appropriate. Adding mode: "no-cors" will not make the response readable.
The Promise rejects before you get a response
This is a network-level failure rather than an ordinary HTTP status response. Check that the URL is valid and reachable from the environment running the code, and inspect any network or runtime error details. The available sources do not establish a universal retry policy; retry only when appropriate for the endpoint and request.
The HTML is missing content visible in a browser
The server response may not contain content inserted later by client-side JavaScript. Fetch does not run that code or render the page. Use the site’s documented data interface when available, or a browser-rendering solution when the rendered result is what you need.
Best Value
fetch is undefined in Node.js
Check the exact Node.js version and runtime with node --version. The Node.js v22.23.3 documentation records Fetch support from v17.5.0 and v16.15.0, with stable status from v21.0.0. An older or different runtime may not provide the same global API.
Performance, reliability, and responsible use
Fetch avoids the work of launching and rendering a browser when you only need the HTTP response body. That can make it a simpler fit for retrieving HTML or JSON, but response time and reliability depend on the destination, network, and runtime; the cited documentation does not provide universal speed or availability figures. For production code, handle rejected requests and unsuccessful HTTP statuses separately, and avoid assuming that a successful response contains fully rendered page content.
Outdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchWindows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallA server-side request does not inherit a visitor’s browser login or browser state simply because it uses the same URL. Do not treat Node.js as a general bypass for access controls. Respect the site’s published API, authentication requirements, rate limits, and applicable terms.
Frequently Asked Questions
Does Fetch download images and other page resources automatically?
No. Fetch retrieves the resource addressed by its request. A browser may separately request resources referenced by HTML while rendering a page.
Can Fetch read a website that requires a login?
Only if the request is legitimately authenticated and the server allows it. Fetch does not automatically use a browser’s logged-in session.
Can I use Fetch to save a webpage as a screenshot?
No. Fetch returns a resource response; it does not render pixels. Use a browser or a browser-based capture service when you need an image of the rendered page.
Do these 3 things before closing this tab:
1Clear out junk files and repair common Windows errors2Scan for outdated or missing drivers - takes under a minute3Repair Windows errors before they cause bigger problemsQuick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

