# djax-client

> A straightforward services client powered by djax.

Latest version **0.2.3** (published 2018-12-12) · MIT license · 0 weekly downloads

## Install

```sh
npm install djax-client
pnpm add djax-client
yarn add djax-client
bun add djax-client
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.3 |
| Published | 2018-12-12 |
| First published | 2015-05-04 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 27.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 7 |
| Author | Guillaume Plique |
| Maintainers | yomguithereal |
| Keywords | client, xhr, ajax, djax, services |

## Links

- npm: https://www.npmjs.com/package/djax-client
- Repository: https://github.com/Yomguithereal/djax-client
- Issues: https://github.com/Yomguithereal/djax-client/issues
- npm.io page: https://npm.io/package/djax-client

## Dependencies (2)

- [djax](https://npm.io/package/djax.md) ^1.2.0
- [object-assign](https://npm.io/package/object-assign.md) ^4.0.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

- 0.2.3 (latest) — 2018-12-12
- 0.2.2 — 2018-12-12
- 0.2.1 — 2016-03-09
- 0.2.0 — 2016-01-13
- 0.1.1 — 2015-09-16
- 0.1.0 — 2015-05-04

## README

# djax-client

A straightforward services client powered by djax.

## Example

```js
var Client = require('djax-client');

// Creating the client
var client = new Client({

  // Client's settings
  settings: {
    baseUrl: 'http://localhost:8000',
    engine: $.ajax,
    scope: null,
    solver: /\:([^/:\?]+)/g
  },

  // Default call options
  defaults: {
    type: 'GET',
    dataType: 'json',
    params: {
      param: 'item',
      dynamicParam: function() {
        return 'user';
      }
    }
  },

  // Defining our services
  services: {
    getItem: '/item/:id',
    getUser: {
      url: '/:param/:id',
      success: function(data) {
        console.log('Got user!', data);
      }
    },
    createItem: {
      url: '/:dynamicParam',
      type: 'POST',
      headers: {
        Authorization: function() {
          return model.getAuth();
        },
        'X-Option': 'hello!'
      }
    }
  }
});

// Using the client
client.request({url: '/items'}, function(err, data) {
  console.log(data);
});

client.request('getItem', {params: {id: 34}}, callback);
client.getItem({params: {id: 34}}, callback);

// etc.
```

## Development

```bash
# Building
npm run build

# Testing
npm test

# Linting
npm run lint

# Working (localhost:7337/static/unit.html)
npm run work
```

## License

MIT

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