Skip to main content

Install the package

npm install wreq-js

Make your first request

For best performance, prefer sessions for anything beyond a single request. One-off fetch() calls are ephemeral by default (fresh cookies/TLS per call), which is great for isolation but usually slower.
import { fetch } from 'wreq-js';

const response = await fetch('https://httpbin.org/get', {
  browser: 'chrome_142',
});

console.log(await response.json());

Use a session for multiple requests

Sessions persist cookies and connection state across requests:
import { createSession } from 'wreq-js';

const session = await createSession({ browser: 'chrome_142' });

// Login
await session.fetch('https://example.com/login', {
  method: 'POST',
  body: new URLSearchParams({ user: 'name', pass: 'secret' }),
});

// Access authenticated endpoint (cookies are preserved)
const account = await session.fetch('https://example.com/account');
console.log(await account.text());

// Clean up
await session.close();

Use a proxy

import { fetch } from 'wreq-js';

const response = await fetch('https://example.com', {
  browser: 'chrome_142',
  proxy: 'http://user:[email protected]:8080',
});

What’s next?