# http-proxy-middleware-body

> Get response body for http-proxy-middleware

Latest version **1.0.0** (published 2023-07-14) · MIT license · 0 weekly downloads

## Install

```sh
npm install http-proxy-middleware-body
pnpm add http-proxy-middleware-body
yarn add http-proxy-middleware-body
bun add http-proxy-middleware-body
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2023-07-14 |
| First published | 2020-10-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 5.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | falalxiao |
| Maintainers | fatalxiao |
| Keywords | http-proxy-middleware |

## Links

- npm: https://www.npmjs.com/package/http-proxy-middleware-body
- Repository: https://github.com/fatalxiao/http-proxy-middleware-body
- Homepage: https://fatalxiao.github.io/http-proxy-middleware-body
- Issues: https://github.com/fatalxiao/http-proxy-middleware-body/issues
- npm.io page: https://npm.io/package/http-proxy-middleware-body

## Dependencies (2)

- [bufferhelper](https://npm.io/package/bufferhelper.md) ^0.2.1
- [concat-stream](https://npm.io/package/concat-stream.md) ^2.0.0

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 1.0.0 (latest) — 2023-07-14
- 0.0.5 — 2020-10-10
- 0.0.4 — 2020-10-09
- 0.0.3 — 2020-10-09
- 0.0.2 — 2020-10-03
- 0.0.1 — 2020-10-03

## README

# http-proxy-middleware-body

[![NPM Version][npm-image]][npm-url]
[![License][license-image]][npm-url]

[npm-image]: https://img.shields.io/npm/v/http-proxy-middleware-body.svg?style=flat-square
[npm-url]: https://npmjs.org/package/http-proxy-middleware-body
[license-image]: https://img.shields.io/npm/l/http-proxy-middleware-body.svg?style=flat-square

Get response body when using `http-proxy-middleware`.

## Example

An example with `express` server.

```javascript
const express = require('express'),
    {createProxyMiddleware} = require('http-proxy-middleware'),
    getBody = require('http-proxy-middleware-body'),

    app = express();

app.use(createProxyMiddleware('SOME_CONTEXT', {

    // other configs...

    onProxyRes: (proxyRes, req, res) => getBody(res, proxyRes, rawBody => {

        if (!rawBody) {
            return;
        }

        try {

            // if it's a json body
            const body = JSON.parse(rawBody);

            // token expired
            if (body.code === 'TOKEN_EXPIRED_CODE') {
                // remove token...
            }

        } catch (e) {
            // do something...
        }

    })

}));
```

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