@unbill/ui-utils

1.9.0 • Public • Published

ui-utils

Common UI functionality used across multiple BDCS UI projects

Environment

import { environment } from '@unbill/ui-utils'

// Gets the current environment production/sandbox/staging/development
environment.getEnvironment(document.location.hostname)

// Gets the API Root of the core API (tentacles)
environment.getCoreApiRoot('development')

Http

// Setup
import { http } from '@unbill/ui-utils'
Vue.Use(http, options)

// Usage
// Options is optional and will use the options passed into the plugin or default options
http.get(url, options)
http.post(url, body, options)
http.delete(url, options)
http.put(url, body, options)

Http Options

// Options and their default values
const options = {
  retryHttpStatii: [502, 503, 504],
  retryMethods: ['get'], //get, post, put, delete supported
  maxRetries: 4,
  retryDelay: 500, //milliseconds with backoff for each successive try
  backOffStrategy: backOffStrategies.Additive //None, Additive, Exponential
  onBefore: [] //Function or array of functions to call before http calls. Don't take parameters.
}

When a response receives an error code, it will automatically throw the response as an error.
To prevent this, in your response handling set suppressThrow on the response object itself to a truthy value.

Dependencies (4)

Dev Dependencies (17)

Package Sidebar

Install

npm i @unbill/ui-utils

Weekly Downloads

21

Version

1.9.0

License

ISC

Unpacked Size

9.1 kB

Total Files

7

Last publish

Collaborators

  • unbill