d8-jsonapi-querystring
Create a Drupal 8 JSON API query string from a nested object
Last updated 3 years ago by yineo .
ISC · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install d8-jsonapi-querystring 
SYNC missed versions from official npm registry.

Drupal 8 JSON API query string builder

Create a Drupal 8 JSON API query string from a nested object.

This make it easier to request a Drupal 8 JSON-API site with JSON API module

If you are looking for a complete JS Client for an API-first Drupal 8, you might be interested in waterwheel.js, as it supports JSON API and more.

You may be interested to use it thoses packages in combination with jsonapi-parse to format json responses in a more intuitive way (it resolves nicely included keys and relationships )

USAGE

To create the following query string :

sort[sortCreated][path]=created&sort[sortCreated][direction]=DESC&fields[recipes]=title&include=tags,image&filter[categoryName][condition][path]=category.name&filter[categoryName][condition][value]=Main%20course&page[offset]=0&page[limit]=4

write:

const buildQueryString = require('d8-jsonapi-querystring').buildQueryString

buildQueryString({
  sort: {
    sortCreated: {
      path: 'created',
      direction: 'DESC'
    }
  },
  fields: {
    recipes: ['title']
  },
  include: ['tags', 'image'],
  filter: {
    categoryName: {
      condition: {
        path: 'category.name',
        value: "Main course"
      }
    },
  },
  page: {
    offset: 0,
    limit: 4
  }
})

Current Tags

  • 0.0.8                                ...           latest (3 years ago)

8 Versions

  • 0.0.8                                ...           3 years ago
  • 0.0.7                                ...           3 years ago
  • 0.0.6                                ...           3 years ago
  • 0.0.5                                ...           3 years ago
  • 0.0.4                                ...           3 years ago
  • 0.0.3                                ...           3 years ago
  • 0.0.2                                ...           3 years ago
  • 0.0.1                                ...           3 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 5
Last Day 0
Last Week 1
Last Month 5
Dependencies (0)
None
Dev Dependencies (6)
Dependents (1)

Copyright 2014 - 2016 © taobao.org |