# drupal-connector

> The Drupal-connector is a helper package for calling Drupal Back-end, and more features.

Latest version **1.0.8** (published 2021-10-08) · MIT license · 0 weekly downloads

## Install

```sh
npm install drupal-connector
pnpm add drupal-connector
yarn add drupal-connector
bun add drupal-connector
```

## Health

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

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.8 |
| Published | 2021-10-08 |
| First published | 2021-10-08 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Node | >=10 |
| Dependencies | 2 |
| Unpacked size | 292.7 KB |
| Known vulnerabilities | 0 (+23 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Author | dongpd1994 |
| Maintainers | dong.pd1994 |

## Links

- npm: https://www.npmjs.com/package/drupal-connector
- Repository: https://github.com/dongpd1994/drupal-connector
- Homepage: https://github.com/dongpd1994/drupal-connector#readme
- Issues: https://github.com/dongpd1994/drupal-connector/issues
- npm.io page: https://npm.io/package/drupal-connector

## Dependencies (2)

- [axios](https://npm.io/package/axios.md) ^0.21.4
- [lodash](https://npm.io/package/lodash.md) ^4.17.21

## Recent versions

- 1.0.8 (latest) — 2021-10-08

## README

# drupal-connector

> The Drupal-connector is a helper package for calling Drupal Back-end, and more features.

[![NPM](https://img.shields.io/npm/v/drupal-connector.svg)](https://www.npmjs.com/package/drupal-connector) [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)

## Install

```bash
npm install --save drupal-connector
```

## Usage

```tsx
import React, { Component } from 'react';

import Drupal from 'drupal-connector';

const ConnectionDrupal = new Drupal({
    baseUrl: 'http://drupal.dd:8083/',
});

const fetchData = async() => {
    const node = await ConnectionDrupal.callAPI('node').get('94e611da-d83b-4d4d-aa4a-b69d00c00112', { bundle: "article" });
    const optionNode = await ConnectionDrupal.callAPI('node').getAll(
      {
        bundle: "article",
        filter: [
          { name_1: { value: "value 1", operator: "CONTAINS", path: "body.value", memberOf:"g_1" } },
          { name_2: { value: "value 2", operator: "CONTAINS", path: "path1", memberOf:"g_2"  } }],
        groups: [
          {g_1 : {group: {conjunction: "OR"}}},
          {g_2 : {group: {memberOf: "g_1", conjunction: "AND"}}}
        ],
        limit: 10,
        offset: 1,
        sort: "-body"
      })
  }
}
```

getNodeByRouter:

- Your front-end page should be a Drupal subdomain.
- Install module in Drupal:
  1. "Decoupled Router" (https://www.drupal.org/project/decoupled_router)
  2. "Subrequests" (https://www.drupal.org/project/subrequests)
  ```bash
    composer require drupal/subrequests
  ```
  3. drupal_connector_helper (https://github.com/dongpd1994/drupal_connector_helper)

```tsx
import React, { Component } from 'react'

import Drupal from 'drupal-connector'

const ConnectionDrupal = new Drupal({
  baseUrl: 'http://drupal.dd:8083/'
})

const fetchData = async () => {
  const node = await ConnectionDrupal.getNodeByRouter('alias-url')
    .catch((error) => {
      console.log(error.message)
    })
    .then((response) => {
      return response
    })
}
```

Field component:

## Configuration

| Name                | Description                                                  | Type    | Required |
| ------------------- | ------------------------------------------------------------ | ------- | -------- |
| include             | The included response of API get content data                | object  | true     |
| value               | The value of field                                           | object  | true     |
| basePath            | If field is image, file then basePath is url of Drupal       | string  | false    |

```jsx
import React, { Component } from 'react';

import Drupal, { FieldBoolean } from 'drupal-connector';

 ...

render(
  <FieldBoolean
    data={{
      include: {},
      value: {}
    }}
    basePath="http://drupal.web.dd:8083"
  />
)

```

## License

MIT © [dongpd1994](https://github.com/dongpd1994)

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