# rexource

> REST API client made ...easy?

Latest version **0.6.0** (published 2017-05-25) · MIT license · 0 weekly downloads

## Install

```sh
npm install rexource
pnpm add rexource
yarn add rexource
bun add rexource
```

## 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.6.0 |
| Published | 2017-05-25 |
| First published | 2017-05-04 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 (+25 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Saran Siriphantnon |
| Maintainers | deoxen0n2 |

## Links

- npm: https://www.npmjs.com/package/rexource
- Repository: https://github.com/deoxen0n2/rexource
- Homepage: https://github.com/deoxen0n2/rexource#readme
- Issues: https://github.com/deoxen0n2/rexource/issues
- npm.io page: https://npm.io/package/rexource

## Dependencies (2)

- [axios](https://npm.io/package/axios.md) ^0.16.1
- [url-join](https://npm.io/package/url-join.md) ^2.0.1

## Recent versions

- 0.6.0 (latest) — 2017-05-25
- 0.5.2 — 2017-05-04
- 0.5.1 — 2017-05-04
- 0.5.0 — 2017-05-04

## README

REST API client made ...easy?

> **Development status:** This is a rather experimental module, so don't use it in any way. The API is not stable and the only use is in the `hipjabber` package that's also an experimental module.

## Install

```sh
$ yarn add rexource   # or npm install --save rexource
```

## Usage

Define:

```js
import { Base, Resource, Resources } from 'rexource'

const Comment = Resource.extend()

const Comments = Resources.extend('comments', {
  Resource: Comment
})

const Post = Resource.extend({
  comments: Comments
})

const Posts = Resources.extend('posts', {
  Resource: Post
})

class Blog extends Base {
  get posts () {
    return new Posts(this.baseURL, this.options)
  }
}
```

Use:

```js
const blog = new Blog('https://example-blog-url.com/api/v2', {
  headers: {
    Authorization: 'Bearer authTokenHere'
  }
})

// Issue POST request to https://example-blog-uri.com/api/v2/posts
blog.posts.create({
  title: 'Hello World!',
  content: 'First post.'
})
.then((post) => {
  // Assuming post.id === '3826',
  // issue POST request to https://example-blog-uri.com/api/v2/posts/3826/comments
  // Also, can use it like blog.posts('3826').comments.create({ ... })
  return post.comments.create({ comment: 'First comment.' })
})
```

## License

Copyright 2017 Saran Siriphantnon &lt;deoxen0n2@gmail.com&gt; MIT License.

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