# @ssdcode/js-caller

> Lightweight axios wrapper

Latest version **1.0.5** (published 2021-01-09) · MIT license · 0 weekly downloads

## Install

```sh
npm install @ssdcode/js-caller
pnpm add @ssdcode/js-caller
yarn add @ssdcode/js-caller
bun add @ssdcode/js-caller
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 1.0.5 |
| Published | 2021-01-09 |
| First published | 2020-05-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 21.9 KB |
| Known vulnerabilities | 0 (+23 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Sebastian Sulinski |
| Maintainers | sebastiansulinski |
| Keywords | axios, axios-wrapper, ajax |

## Links

- npm: https://www.npmjs.com/package/@ssdcode/js-caller
- Repository: https://github.com/sebastiansulinski/js-caller
- Homepage: https://github.com/sebastiansulinski/js-caller#readme
- Issues: https://github.com/sebastiansulinski/js-caller/issues
- npm.io page: https://npm.io/package/@ssdcode/js-caller

## Dependencies (1)

- [axios](https://npm.io/package/axios.md) ^0.21.1

## 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

- 1.0.5 (latest) — 2021-01-09
- 1.0.4 — 2020-07-15
- 1.0.3 — 2020-06-05
- 1.0.2 — 2020-05-28
- 1.0.1 — 2020-05-22
- 1.0.0 — 2020-05-22

## README

# JS Caller

Lightweight [axios](https://github.com/axios/axios) wrapper pre-configured with the following headers:

```javascript
'X-Requested-With': 'XMLHttpRequest'
Accept: 'application/json'
'Content-Type': 'application/json'
```

### Installation

```bash
npm i @ssdcode/js-caller
```

### Usage

```bash
import Caller from '@ssdcode/js-caller';

Caller.request(
  '/end-point',
  'post',
  { id: 1 },
  {
    timeout: 1000,
    headers: { 'X-Custom-Header': 'foobar' },
  }
);
```

`Caller.request` method takes 4 arguments:

```bash
- endpoint: request destination
- request method: get (default), post, put, patch, delete
- payload: data you wish to send with the request. If request method is in ['post', 'put', 'patch'] - payload will automaticaly be associated with 'data' index - otherwise 'params' will be used
- config: axios specific configuration
```

If you're using `csrf` token, make sure it is included as a meta tag and `js-caller` will fetch and attach it to the request automatically as a `X-CSRF-TOKEN` header.

```html
<meta name="csrf-token" content="{{ csrf_token() }}">
```

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