Assets

Assets

new Assets(uid) → {Assets}

Creates an instance of `Assets`.

Retrieves all assets of a stack by default. To retrieve a single asset, specify its UID.
Parameters:
Name Description
uid uid of asset you want to retrieve
Examples
let data = Stack.Assets('asset_uid').toJSON().fetch()
     data
     .then(function(result) {
          // ‘result’ is a single asset object of specified uid       
     }, function(error) {
          // error function
     })
// Retrieves all assets*
let data = Stack.Assets().Query().toJSON().find()
     data
     .then(function(result) {
         // All the asset with limit of 100
         // Use skip and limit functions to paginate
         // ‘result’ will display all assets present in stack       
     }, function(error) {
          // error function
     })

Methods

toJSON() → {Assets}

Converts your response into plain JavasScript object
Example
var Query = Stack.ContentType('blog').Query()
    Query   
         .toJSON()
         .find()
         .then(function (result) {
             // 'result' is an object which content the data in json object form
          },function (error) {
             // error function
     })

addParam() → {Assets}

Includes query parameters in your queries.
Example
var data = Stack.Assets(assetUid).addParam('include_dimension', 'true').toJSON().fetch()
     data.then(function (result) {
         // 'result' is an object which content the data including count in json object form
      },function (error) {
         // error function
     })

fetch() → {promise}

Fetches a particular asset based on the provided asset UID.
Examples
Stack.Assets('assets_uid').toJSON().fetch()
Stack.Assets('assets_uid').toJSON().fetch({
        
     })