@adobe/aio-lib-core-networking

Adobe I/O Lib Core Networking

Usage no npm install needed!

<script type="module">
  import adobeAioLibCoreNetworking from 'https://cdn.skypack.dev/@adobe/aio-lib-core-networking';
</script>

README

Version Downloads/week Build Status License Greenkeeper badge Codecov Coverage

Adobe I/O Core Networking Lib

Installing

$ npm install @adobe/aio-lib-core-networking

Usage

  1. Initialize the SDK
const fetchRetry = require('@adobe/aio-lib-core-networking')

  1. Call methods using the initialized SDK

const fetchRetry = require('@adobe/aio-lib-core-networking')
async function sdkTest() {

  return new Promise((resolve, reject) => {
    fetchRetry.exponentialBackoff(url, requestOptions, retryOptions, retryOn, retryDelay)
    .then((response) => {
      if (!response.ok) {
        throw Error(reduceError(response))
      }
      resolve(response.json())
    })
    .catch(err => {
      reject(
        new codes.ERROR_GET_SOMETHING({ sdkDetails, messageValues: err }))
    })
  }) 
}

@adobe/aio-lib-core-networking

Working of HttpExponentialBackoff

image not available

@adobe/aio-lib-core-networking~HttpExponentialBackoff

This class provides methods to implement fetch with retries. The retries use exponential backoff strategy with defaults set to max of 3 retries and initial Delay as 100ms

Kind: inner class of @adobe/aio-lib-core-networking

httpExponentialBackoff.exponentialBackoff(url, requestOptions, retryOptions, retryOn, retryDelay) ⇒ Promise.<Response>

This function will retry connecting to a url end-point, with exponential backoff. Returns a Promise.

Kind: instance method of HttpExponentialBackoff
Returns: Promise.<Response> - Promise object representing the http response

Param Type Description
url string endpoint url
requestOptions object request options which includes the HTTP method, headers, timeout, etc.
retryOptions object retry options with options being maxRetries and initialDelayInMillis
retryOn function | Array Optional Function or Array. If provided, will be used instead of the default
retryDelay function | number Optional Function or number. If provided, will be used instead of the default

Debug Logs

LOG_LEVEL=debug <your_call_here>

Prepend the LOG_LEVEL environment variable and debug value to the call that invokes your function, on the command line. This should output a lot of debug data for your SDK calls.

Contributing

Contributions are welcome! Read the Contributing Guide for more information.

Licensing

This project is licensed under the Apache V2 License. See LICENSE for more information.