1.0.0 • Published 7 years ago

lib-bb-portal-rest-ajax-adapter v1.0.0

Weekly downloads
5
License
-
Repository
-
Last release
7 years ago

lib-bb-portal-rest-ajax-adapter

Version: 1.0.0

Browser AJAX adapter for lib-bb-portal-rest

Example

import bbrest from 'lib-bb-portal-rest';
import adapter from 'lib-bb-portal-rest-ajax-adapter';

const BBRest = bbrest(adapter);

BBRest.server().get()
  .then(portals => {
    // do something
  });

Table of Contents

  • Exports default(logFunction)
  • Type Definitions requestCallback(config, payload) AjaxAdapter logCallback(header, message) btoaCallback(string) Response

Exports

default(logFunction)

ParameterTypeDescription
logFunctionFunction (optional)function to use for logging
Returns

AjaxAdapter - Adapter API

Type Definitions

requestCallback(config, payload)

Executes http request.

ParameterTypeDescription
configObjecthttp request configuration
config.urlStringtarget url
config.methodStringhttp method
config.queryObjecthttp param query hash
config.headersObjectheaders hash
config.importFileStringfile blob object
config.exportFileStringpath of the file to download to
config.formFieldStringname of the form field for upload
payloadStringxml string or url of xml to sent as request body
Returns

Response - response object

AjaxAdapter

Type: Object

PropertyTypeDescription
requestrequestCallbackhttp request method
loglogCallbacklog method
btoabtoaCallbackbase64 string convert method
DOMParserDOMParserSee https://developer.mozilla.org/en-US/docs/Web/API/DOMParser

logCallback(header, message)

logs message with header

ParameterTypeDescription
headerStringtitle of the message
messageStringmessage to log

btoaCallback(string)

returns a base-64 encoded ASCII string from a String object

ParameterTypeDescription
stringStringto encode
Returns

String - encodedString

Response

Type: Object

PropertyTypeDescription
statusNumberhttp status code
statusTextStringhttp status text
headersObjecthttp response headers
bodyStringhttp response body