Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

Callable

  • Converts a Request into a Response by running the request through an appropriate Adapter.

    throws

    Adapter not found.

    throws

    Invalid request passed to fetch.

    throws

    (if the Response.status is not 2xx)

    example
    import xhr from '@paychex/adapter-xhr';
    import tracker from '~/path/to/tracker';
    import proxy from '~/path/to/proxy';

    // NOTE: you will probably already have access to
    // a datalayer and not need to create one yourself
    const { fetch, createRequest } = data.createDataLayer(proxy, xhr);

    const request = createRequest({
    base: 'my-app',
    path: '/live',
    });

    fetch(request)
    .then(response => {
    tracker.event('app is live', {
    status: response.status,
    message: response.statusText,
    moreInfo: response.data,
    });
    })
    .catch(tracker.error);

    Parameters

    Returns Promise<Response>

    A Promise resolved with response information for the request.