Glossary
Axios: an HTTP client for Node.js and the browser
Axios is a JavaScript HTTP client that works in Node.js and in browsers, returns promises, and adds conveniences such as instances, interceptors and automatic JSON handling.
What it offers over raw HTTP
Axios has been a staple of JavaScript projects for years. Compared with lower level options it gives you automatic JSON encoding and parsing, a single error type for network failures and bad statuses, request and response interceptors, configurable instances with shared defaults, and timeout support with one option. Since Node.js 18 the built in Fetch API covers the basics too, so choosing between them is now a matter of taste and features.
Instances and defaults
import axios from "axios";
const shop = axios.create({
baseURL: "https://shop.example",
timeout: 20000,
headers: { "Accept-Language": "en-US,en;q=0.9" },
});
const { data } = await shop.get("/api/items", { params: { page: 2, size: 48 } });
console.log(data.items.length);
An instance keeps the base URL, timeout and headers in one place. The params option builds the query string for you and handles encoding.
Interceptors
Interceptors run before each request and after each response. Scrapers use them to log timings, add headers, or detect blocks centrally. A response interceptor that turns a 403 or 429 into a typed error lets the rest of your code react in one consistent way, for example by backing off or by triggering a challenge solve.
Errors and statuses
By default Axios rejects the promise for any status outside 2xx. The error object carries response.status and response.data, so you can still read the body of a 403 page and check whether it is a challenge. If you prefer to inspect every status yourself, set validateStatus: () => true on the instance.
Fingerprint limits
In Node.js, Axios uses the standard http and https modules. That means HTTP/1.1, Node's own TLS handshake and a short default header set. Protected sites recognize these patterns, the same way they recognize Python Requests. Setting a browser user agent helps a little; it does not change the TLS fingerprint. For heavily protected targets, render the first page with a browser and reuse the cookies, or accept that challenges will appear and handle them.
Calling GateSolver with Axios
A compact helper that creates a task and waits for the answer:
const gs = axios.create({ baseURL: "https://gatesolver.com", timeout: 15000 });
const threeSeconds = () => new Promise((done) => setTimeout(done, 3000));
async function awaitToken(task) {
const made = await gs.post("/createTask", { clientKey: "YOUR_API_KEY", task });
if (made.data.errorId !== 0) throw new Error(`create: ${made.data.errorCode}`);
for (;;) {
await threeSeconds();
const { data: r } = await gs.post("/getTaskResult",
{ clientKey: "YOUR_API_KEY", taskId: made.data.taskId });
if (r.errorId || r.status === "failed") throw new Error(r.errorCode ?? "task failed");
if (r.status !== "processing") return r.solution; // token, cookie or text
}
}
Pass it a task such as { type: "ReCaptchaV3TaskProxyLess", websiteURL, websiteKey, pageAction: "search" }. A reCAPTCHA v3 token typically comes back under 3 seconds; failed tasks are not charged. Add the token to the request the site expects, usually a JSON field or form value. See scraping with Axios for a complete scraper and Cheerio for parsing the HTML you fetch.
Common questions
Should I use Axios or the built in fetch?
Both work. Fetch is built in since Node.js 18; Axios adds interceptors, instances, automatic JSON and simpler timeouts.
Why does Axios throw on a 403 response?
It rejects any status outside 2xx by default. Read error.response or change validateStatus to handle statuses yourself.
Does Axios support HTTP/2 in Node.js?
Not by default. It uses the standard http and https modules, which speak HTTP/1.1.
Can I set a timeout for every Axios request?
Yes. Set timeout on an instance and every request made through it inherits the value.
How do I send a solved token with Axios?
Include it in the body or header the site expects, for example as g-recaptcha-response in a form post.
Keep reading
- Web scraping with Axios and CheerioA Node.js scraper on Axios and Cheerio: a configured instance, a retry interceptor, jQuery style parsing and a small pool.
- Fetch APIThe standard promise based way to make HTTP requests in browsers, now built into Node.js, Deno and Bun as well.
- CheerioA fast Node.js library that parses HTML on the server and lets you query it jQuery style, no browser needed.
- Solve reCAPTCHA v2 in Node.jsUse the fetch API built into Node.js 18+ to get a reCAPTCHA v2 token, then place it inside a live Puppeteer page.