# fresource

> A full featured Rest API client around window.fetch to provide idiomatic interaction.

Latest version **0.8.0** (published 2024-01-05) · MIT license · 0 weekly downloads

## Install

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

## 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.8.0 |
| Published | 2024-01-05 |
| First published | 2018-11-07 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 9.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 6 |
| Author | Ismail Demirbbilek |
| Maintainers | dbtek |
| Keywords | rest, api, client, zero-dependency, tiny, micro, fetch, ajax, resource |

## Links

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

## 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.8.0 (latest) — 2024-01-05
- 0.7.0 — 2019-03-05
- 0.6.0 — 2019-02-08
- 0.5.1 — 2019-02-06
- 0.5.0 — 2019-02-06
- 0.4.0 — 2019-01-31
- 0.3.0 — 2019-01-31
- 0.2.0 — 2018-12-05
- 0.1.0 — 2018-11-07

## README

<div align="center">
  <h1>f·resource</h1>
  <!-- Test Coverage -->
  <a href="https://codecov.io/github/dbtek/fresource">
    <img src="https://img.shields.io/codecov/c/github/dbtek/fresource/main.svg?style=for-the-badge"
      alt="Test Coverage" />
  </a>
  <!-- Standard -->
  <a href="https://standardjs.com">
    <img src="https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=for-the-badge&logo=javascript"
      alt="Standard" />
  </a>
</div>
<br/>
<div align="center">
  All in one client for your REST API under 1kB. 
</div>

## Install
With npm:
```bash
$ npm i fresource --save
```

Via CDN:
```html
<script src="https://unpkg.com/fresource/dist/fresource.js"></script>
```

## Usage
```js
var fresource = require('fresource')

var Users = fresource('/api/users/:id?sort=:sort')

Users.get({ sort: 'name' }) // will fetch /api/users?sort=name
  .then(result => {
    var users = result
  })

Users.get({ id: 1 }) // will fetch /api/users/1
  .then(result => {
    var user = result
  })
```

## API

**Collection = fresource(path)**  
Initialize a resource with a path / url. Path should include all path / query parameter variables like `:key`.

**Collection.get(params)**  
Fetches a `GET` request with given parameters.  
Returns promise.

**Collection.save(params)**  
Sends a `POST` request with given parameters. Residual parameters that are not used in url will be posted in body.  
Returns promise.

**Collection.update(params)**  
Sends a `PUT` request with given parameters. Residual parameters that are not used in url will be posted in body.  
Returns promise.

**Collection.delete(params)**  
Sends a `DELETE` request with given parameters.  
Returns promise.

## Author
Ismail Demirbilek [@dbtek](https://twitter.com/dbtek)

## License
MIT

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