# dash-restful

> A JavaScript restful client using fetch interface.

Latest version **0.2.1** (published 2022-08-22) · MIT license · 0 weekly downloads

## Install

```sh
npm install dash-restful
pnpm add dash-restful
yarn add dash-restful
bun add dash-restful
```

## Health

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

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.1 |
| Published | 2022-08-22 |
| First published | 2020-10-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=10 |
| Dependencies | 0 |
| Unpacked size | 75.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Maintainers | charlee |

## Links

- npm: https://www.npmjs.com/package/dash-restful
- Repository: https://github.com/charlee/dash-restful
- Homepage: https://github.com/charlee/dash-restful#readme
- Issues: https://github.com/charlee/dash-restful/issues
- npm.io page: https://npm.io/package/dash-restful

## Recent versions

- 0.2.1 (latest) — 2022-08-22
- 0.1.3 — 2020-12-12
- 0.1.2 — 2020-12-12
- 0.1.1 — 2020-10-10
- 0.1.0 — 2020-10-10

## README

# dash-restful

A JavaScript restful client using fetch interface.

## Install

```
npm i dash-restful
```

or

```
yarn add dash-restful
```

## Usage

The simplest way is to create an API object and use it to access the endpoints:

```typescript
import DashApi from 'dash-restful';

type Book = {
  id: number;
  name: string;
  author: string;
};

// Create an api instance and use the low level API
const api = DashApi('https://api.example.com/');

api
  .post<Book>('/books/', {
    data: {
      name: 'War and Peace',
      author: 'Leo Tolstoy',
    },
  })
  .then((book) => {
    console.log(book);
  });

// or use async call
const book: Book = await api.get<Book>('/books/1');
console.log(book); // type: Book
```

A more recommended approach is to use the high-level, REST-aware "resource" API:

```typescript
// create a high-level, REST-aware resource
const bookResource = api.createResource<Book>('books');
bookResource
  .create({
    name: 'War and Peace',
    author: 'Leo Tolstoy',
  })
  .then((book: Book) => {
    console.log(book);
  });

const book2 = await bookResource.retrieve(1);
console.log(book2);
```

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