# ra-data-lb4

> React Admin Loopback4 CRUD DataProvider

Latest version **0.4.0** (published 2021-09-12) · MIT license · 0 weekly downloads

## Install

```sh
npm install ra-data-lb4
pnpm add ra-data-lb4
yarn add ra-data-lb4
bun add ra-data-lb4
```

## Health

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

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

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.4.0 |
| Published | 2021-09-12 |
| First published | 2020-12-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 19.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 4 |
| Author | KoLiBer |
| Maintainers | koliber |
| Keywords | ra, react, admin, react-admin, dataprovider, loopback4, loopback, lb4 |

## Links

- npm: https://www.npmjs.com/package/ra-data-lb4
- Repository: https://github.com/ckoliber/ra-data-lb4
- Homepage: https://github.com/ckoliber/ra-data-lb4#readme
- Issues: https://github.com/ckoliber/ra-data-lb4/issues
- npm.io page: https://npm.io/package/ra-data-lb4

## Alternatives

- [@sveltejs/kit](https://npm.io/package/@sveltejs/kit.md) — 2.2M weekly downloads
- [@atlaskit/theme](https://npm.io/package/@atlaskit/theme.md) — 402.0K weekly downloads
- [@tangle-network/brand](https://npm.io/package/@tangle-network/brand.md) — 10.0K weekly downloads
- [seneca](https://npm.io/package/seneca.md) — 7.4K weekly downloads
- [@bsb/base](https://npm.io/package/@bsb/base.md) — 7.2K weekly downloads

## Recent versions

- 0.4.0 (latest) — 2021-09-12
- 0.4.1-next.2 (next) — 2021-11-15
- 0.4.1-next.1 — 2021-09-12
- 0.3.0 — 2020-12-09
- 0.2.0 — 2020-12-06
- 0.1.0 — 2020-12-06

## README

# ra-data-lb4

![Travis (.org) branch](https://img.shields.io/travis/ckoliber/ra-data-lb4/master)
![npm](https://img.shields.io/npm/v/ra-data-lb4)
![npm bundle size](https://img.shields.io/bundlephobia/min/ra-data-lb4)
![GitHub](https://img.shields.io/github/license/ckoliber/ra-data-lb4)

React Admin Loopback4 CRUD DataProvider

## Installation

```bash
npm i --save ra-data-lb4
```

## Usage

```tsx
// in src/App.tsx
import React from "react";
import { Admin, Resource } from "react-admin";
import lb4Provider from "ra-data-lb4";

import { PostList } from "./posts";

const App = () => (
    <Admin dataProvider={lb4Provider("http://path.to.my.api/")}>
        <Resource name="posts" list={PostList} />
    </Admin>
);

export default App;
```

---

## Model Aggregation

**Loopback4** supports model aggregations using **inclusion resolvers**, you can pass your `include` params per model:

```tsx
// in src/App.tsx
import { Admin, Resource } from "react-admin";
import lb4Provider from "ra-data-lb4";

const aggregate = (resource: string) => {
    if (resource === "posts") {
        return [
            {
                relation: "author",
            },
        ];
    }

    return [];
};

const provider = lb4Provider("http://path.to.my.api/", aggregate);
```

---

## Customizing Http Client

```tsx
// in src/App.tsx
import { fetchUtils, Admin, Resource } from "react-admin";
import lb4Provider from "ra-data-lb4";

const httpClient = (url, options = {}) => {
    if (!options.headers) {
        options.headers = new Headers({ Accept: "application/json" });
    }
    // add your own headers here
    options.headers.set("X-Custom-Header", "foobar");
    return fetchUtils.fetchJson(url, options);
};

const provider = lb4Provider("http://path.to.my.api/", undefined, httpClient);
```

---

## Contributors

-   [KoLiBer](https://www.linkedin.com/in/mohammad-hosein-nemati-665b1813b/)

## License

This project is licensed under the [MIT license](LICENSE.md).  
Copyright (c) KoLiBer (koliberr136a1@gmail.com)

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