drupal-connector
TypeScript icon, indicating that this package has built-in type declarations

1.0.8 • Public • Published

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

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
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

Readme

Keywords

none

Package Sidebar

Install

npm i drupal-connector

Weekly Downloads

1

Version

1.0.8

License

MIT

Unpacked Size

300 kB

Total Files

50

Last publish

Collaborators

  • dong.pd1994