# puppeteer-fetch

> Fetch with Puppeteer, just like node-fetch, but use puppeteer as the driver

Latest version **0.3.1** (published 2022-02-14) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install puppeteer-fetch
pnpm add puppeteer-fetch
yarn add puppeteer-fetch
bun add puppeteer-fetch
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.3.1 |
| Published | 2022-02-14 |
| First published | 2021-02-20 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >= 14.15 |
| Dependencies | 3 |
| Unpacked size | 46.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 8 |
| Author | Owen Young |
| Maintainers | theowenyoung |
| Keywords | puppeteer, fetch, scrape, waf, axios, http, request |

## Links

- npm: https://www.npmjs.com/package/puppeteer-fetch
- Repository: https://github.com/theowenyoung/puppeteer-fetch
- Homepage: https://github.com/theowenyoung/puppeteer-fetch#readme
- Issues: https://github.com/theowenyoung/puppeteer-fetch/issues
- npm.io page: https://npm.io/package/puppeteer-fetch

## Dependencies (3)

- [tslib](https://npm.io/package/tslib.md) ~2.0.3
- [puppeteer](https://npm.io/package/puppeteer.md) ^13.3.2
- [handlebars](https://npm.io/package/handlebars.md) ^4.7.7

## Alternatives

- [launchdarkly-js-client-sdk](https://npm.io/package/launchdarkly-js-client-sdk.md) — 2.5M weekly downloads
- [@elastic/elasticsearch](https://npm.io/package/@elastic/elasticsearch.md) — 2.1M weekly downloads
- [@c8y/client](https://npm.io/package/@c8y/client.md) — 15.3K weekly downloads
- [@signaldb/maverickjs](https://npm.io/package/@signaldb/maverickjs.md) — 1.7K weekly downloads
- [@bbc/http-transport-cache](https://npm.io/package/@bbc/http-transport-cache.md) — 1.2K weekly downloads

## Recent versions

- 0.3.1 (latest) — 2022-02-14
- 0.3.0 — 2021-11-26
- 0.2.1 — 2021-06-29
- 0.2.0 — 2021-06-29
- 0.1.7 — 2021-02-20
- 0.1.6 — 2021-02-20
- 0.1.5 — 2021-02-20
- 0.1.4 — 2021-02-20
- 0.1.3 — 2021-02-20
- 0.1.2 — 2021-02-20
- 0.1.1 — 2021-02-20

## README

# puppeteer-fetch

## Table of Contents

- [About](#about)
- [Getting Started](#getting_started)
- [Usage](#usage)
- [Contributing](../CONTRIBUTING.md)

## About <a name = "about"></a>

Fetch with Puppeteer, just like node-fetch, but use [puppeteer](https://pptr.dev/) as the driver.

## Getting Started <a name = "getting_started"></a>

```javascript
const fetch = require("puppeteer-fetch").default;

(async () => {
  const response = await fetch("https://jsonplaceholder.typicode.com/posts", {
    method: "POST",
    body: JSON.stringify({
      title: "foo",
      body: "bar",
      userId: 1,
    }),
    headers: {
      "Content-type": "application/json; charset=UTF-8",
    },
  });
  const ok = response.ok;
  if (ok) {
    const result = await response.json();
    console.log("result", result);
    // print { title: 'foo', body: 'bar', userId: 1, id: 101 }
  }
})();
```

### Installing

```
npm i puppeteer-fetch
```

## Usage <a name = "usage"></a>

> fetchOptions see [Fetch_API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch)

> puppeteerConfig see [puppeteer](https://pptr.dev/)

```typescript
const fetch = require('puppeteer-fetch');

fetch('<url>', fetchOptions, {
  puppeteerConfig: IPuppeteerConfig,
  timeout: number,
  puppeteer: PuppeteerNode
});

// you can pass a puppeteer instant, like puppeteer-extra

interface IPuppeteerConfig {
  launchOptions?: LaunchOptions & ChromeArgOptions & BrowserOptions;
  userAgent?: string;
  viewPort?: {
    width: number;
    height: number;
    deviceScaleFactor?: number;
    isMobile?: boolean;
    isLandscape?: boolean;
    hasTouch?: boolean;
  };
  waitFor?: WaitForOptions;
  extraHTTPHeaders?: Record<string, string>;
}
```

---
_Source: https://npm.io/package/puppeteer-fetch · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
