1.0.8 • Published 3 years ago

drupal-connector v1.0.8

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

drupal-connector

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

NPM JavaScript Style Guide

Install

npm install --save drupal-connector

Usage

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:

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

NameDescriptionTypeRequired
includeThe included response of API get content dataobjecttrue
valueThe value of fieldobjecttrue
basePathIf field is image, file then basePath is url of Drupalstringfalse
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

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago