# tiny-json-http

> Minimalist `HTTP` client for `GET`, `POST`, `PUT`, `PATCH` and `DELETE` `JSON` payloads

Latest version **7.5.1** (published 2023-03-29) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install tiny-json-http
pnpm add tiny-json-http
yarn add tiny-json-http
bun add tiny-json-http
```

## Health

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

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

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 7.5.1 |
| Published | 2023-03-29 |
| First published | 2016-10-30 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | separate (@types/tiny-json-http) |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 42.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 174 |
| Author | Brian LeRoux |
| Maintainers | brianleroux |

## Links

- npm: https://www.npmjs.com/package/tiny-json-http
- Repository: https://github.com/brianleroux/tiny-json-http
- Homepage: https://github.com/brianleroux/tiny-json-http#readme
- Issues: https://github.com/brianleroux/tiny-json-http/issues
- npm.io page: https://npm.io/package/tiny-json-http

## Recent versions

- 7.5.1 (latest) — 2023-03-29
- 7.5.0 — 2023-03-02
- 7.4.2 — 2022-03-15
- 7.4.1 — 2022-03-15
- 7.4.0 — 2022-03-15
- 7.3.1 — 2021-10-14
- 7.3.0 — 2020-10-02
- 7.2.2 — 2020-08-10
- 7.2.1 — 2020-08-10
- 7.2.0 — 2020-05-15
- 7.1.2 — 2019-04-03
- 7.1.1 — 2019-04-03
- 7.1.0 — 2019-04-03
- 7.0.2 — 2018-10-24
- 7.0.1 — 2018-10-23
- … 30 more at https://npm.io/package/tiny-json-http/versions

## README

# tiny-json-http

Minimalist `HTTP` client for `GET`, `POST`, `PUT`, `PATCH` and `DELETE` `JSON` payloads

- Zero dependencies: perfect for AWS Lambda
- Sensible default: assumes buffered JSON responses
- System symmetry: Node style errback API, or Promises for use with Async/Await

```bash
npm i tiny-json-http --save
```

### API

#### Read methods
- `tiny.get(options[, callback])`
- `tiny.head(options[, callback])`
- `tiny.options(options[, callback])`

#### Write methods
- `tiny.post(options[, callback])`
- `tiny.put(options[, callback])`
- `tiny.patch(options[, callback])`
- `tiny.del(options[, callback)]`

_*callback is optional, tiny methods will return a promise if no callback is provided_

### Options

- `url` *required*
- `data` form vars for `tiny.post`, `tiny.put`, `tiny.patch`, and `tiny.delete` otherwise querystring vars for `tiny.get`
- `headers` key/value map used for headers (including support for uploading files with `multipart/form-data`)
- `buffer` if set to `true` the response body is returned as a buffer

### Callback values

- `err` a real javascript `Error` if there was one
- `data` an object with `headers` and `body` keys

### Promises

- if no `callback` is provided to the tiny-json-http methods, a promise is returned
- perfect for use of async/await

## Examples

#### With Async / Await

```javascript
var tiny = require('tiny-json-http')
var url = 'http://www.randomkittengenerator.com'

;(async function _iife() {
  try {
    console.log(await tiny.get({url}))
  } catch (err) {
    console.log('ruh roh!', err)
  }
})();
```

#### With Callback

```javascript
var tiny = require('tiny-json-http')
var url = 'http://www.randomkittengenerator.com'

tiny.get({url}, function _get(err, result) {
  if (err) {
    console.log('ruh roh!', err)
  }
  else {
    console.log(result)
  }
})
```

Check out the tests for more examples! :heart_decoration:

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