Comfortable | Docs
  • Comfortable Documentation
  • Concepts
    • Content Repositories
    • Content Types
    • Documents
    • Assets
    • Content Tree
    • Collections
    • Webhooks
    • Team
    • Locales
  • APIs
    • RESTful API
      • Endpoints
      • API Reference
        • Sorting
        • Filters
        • Localisation
        • Fields
        • Includes
        • Search
      • Query Examples
        • Collections
        • Single Documents
        • Single Assets
        • Sorting
        • Filters
        • Includes
    • Image Manipulation
  • SDKs
    • JavaScript
      • Query Options
      • Query All Documents
      • Query a Collection
      • Query a Single Document
      • Query an Alias
      • Query an Asset
      • Example: Filters
      • Example: Sorting
    • Nuxt.js
    • PHP
      • Query All Documents
      • Query Single Document
      • Query Collection
      • Query an Alias
      • Query an Asset
      • Fulltext Search
      • Query by Fields
      • Query by Type
      • Query by Id
      • Query by Tags
  • Guides
    • Vue Blog Example
  • Legal
    • Legal Notice
    • Privacy Policy
Powered by GitBook
On this page
  • Installation
  • Include the dependency
  • Connect to your Repository and make your first request:
  • Options
  1. SDKs

JavaScript

PreviousImage ManipulationNextQuery Options

Last updated 5 years ago

Installation

NPM

Run this command:

npm install comfortable-javascript

For Usage in Browser

<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/comfortable-javascript@latest/dist/comfortable.min.js"></script>

Note: For a specific version replace @latest with the version of your choice.

The SDK will be available as a global variable called: Comfortable

Downloadable version

Check out the release Page:

Include the dependency

const Comfortable = require('comfortable-javascript');

Connect to your Repository and make your first request:

const api = Comfortable.api('<repository-api-id>', '<api-key>', options);

api.getDocuments()
  .then(result => {
    // futher implementation
  })
  .catch(err => {
    throw err;
  })

Full Query example

const api = Comfortable.api('<repository-api-id>', '<api-key>', options);

api.getDocuments({
  limit: 25,
  offset: 0,
  locale: 'en',
  includes: 2,
  includeTags: ['include', 'me'],
  excludeTags: ['exclude', 'this'],
  fields: 'meta,fields(title)',
  embedAssets: true,
  filters: new Comfortable.Filter()
    .addAnd('title', 'like', '%Hello%')
    .addOr('title', 'like', '%World%'),
  sorting: new Comfortable.Sorting()
    .add('date', 'asc')
    .add('title', 'asc'),
  search: 'sport -football +soccer'
})
  .then(result => {
    // futher implementation
  })
  .catch(err => {
    throw err;
  })

Options

Option

Type

Description

useProxy

boolean

proxy

string

list of options can be found .

enables the usage of a Proxy Endpoint instead of using

Proxy Url (e.g. )

https://github.com/cmftable/comfortable-javascript/releases
here
https://api.cmft.io/v1
https://custom-api.com/v1