# parse-json-response

> Gather up a JSON response from a server, and call the cb

Latest version **1.0.1** (published 2014-01-13) · ISC license · 0 weekly downloads

## Install

```sh
npm install parse-json-response
pnpm add parse-json-response
yarn add parse-json-response
bun add parse-json-response
```

## 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.1 |
| Published | 2014-01-13 |
| First published | 2014-01-04 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 7 |
| Author | Isaac Z. Schlueter |
| Maintainers | isaacs |
| Keywords | parse, json, http, response |

## Links

- npm: https://www.npmjs.com/package/parse-json-response
- Repository: https://github.com/isaacs/parse-json-response
- Issues: https://github.com/isaacs/parse-json-response/issues
- npm.io page: https://npm.io/package/parse-json-response

## Dependencies (1)

- [once](https://npm.io/package/once.md) ~1.3.0

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 1.0.1 (latest) — 2014-01-13
- 1.0.0 — 2014-01-04

## README

# parse-json-response

Gather up a JSON response from a server, and call the cb

## USAGE

```javascript
var parse = require('parse-json-response')

// Handy response-event-handler function returny thing

// parse(cb) -> function(res)
http.get(someApi, parse(function(er, data, res) {
  if (er)
    console.error('it failed', res.headers, er)
  else
    console.error('it worked', res.headers, data)
}))

// or, if you have the response object somehow already

http.get(someApi, function(res) {
  // parse(res, cb) -> null
  parse(res, function(er, data) {
    if (er)
      console.error('it failed', res.headers, er)
    else
      console.error('it worked', res.headers, data)
  })
})
```

If the response statusCode is not in the 2xx range, then it's assumed
to be an error, and will create an error object.  The error object
returned is decorated with `statusCode`.  The `data` arg is always set
if the response body was parseable.

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