api

api

new api(fluro)

Source:
Creates a new FluroAPI instance. This module is a wrapper around the axios package. It aims to make it easier for you to connect with and consume endpoints from the Fluro REST API for more information about the available endpoints see Fluro REST API Documentation
Parameters:
Name Type Description
fluro FluroCore A reference to the parent instance of the FluroCore module. The FluroAPI module is usually created by a FluroCore instance that passes itself in as the first argument.

Methods

(static) delete(path, config)

Source:
Makes a delete http request to the Fluro REST API
Example
fluro.api.delete('/content/article/5ca3d64dd2bb085eb9d450db')
.then(function (response) {
  console.log(response);
})
.catch(function (error) {
  console.log(error);
});
Parameters:
Name Type Description
path String The Fluro API endpoint to request
config Object Optional parameters for the request

(static) generateEndpointURL(endpoint, params) → {string}

Source:
A helper function for generating an authenticated url for the current user
Example
// returns 'https://api.fluro.io/something?access_token=2352345...'
fluro.api.generateEndpointURL('/something');
Parameters:
Name Type Description
endpoint string The id of the asset, or the asset object you want to download
params object
Returns:
A full URL with relevant parameters included
Type
string

(static) get(path, config)

Source:
Makes a get http request to the Fluro REST API
Example
//Make a request to get the current user session
fluro.api.get('/content/article', {
  params:{
    select:'title created',
    limit:10,
    simple:true,
  }
})
.then(function (response) {
  console.log(response);
})
.catch(function (error) {
  console.log(error);
});
Parameters:
Name Type Description
path String The Fluro API endpoint to request
config Object Optional parameters for the request

(static) post(path, config)

Source:
Makes a post http request to the Fluro REST API
Example
fluro.api.post('/content/article', {title:'my new article', ...}, {
  //headers and other things
})
.then(function (response) {
  console.log(response);
})
.catch(function (error) {
  console.log(error);
});
Parameters:
Name Type Description
path String The Fluro API endpoint to request
config Object Optional parameters for the request

(static) put(path, config)

Source:
Makes a put http request to the Fluro REST API
Example
fluro.api.put('/content/article/5ca3d64dd2bb085eb9d450db', {title:'my new article', ...}, {
  //headers and other things
})
.then(function (response) {
  console.log(response);
})
.catch(function (error) {
  console.log(error);
});
Parameters:
Name Type Description
path String The Fluro API endpoint to request
config Object Optional parameters for the request