Skip to main content
Version: 5.x.x

Adapter


info

HyperFetch ships with predefined adapters for the browser and node environments. You do not need to install any additional dependencies or event setting up the adapter. It is ready to use out of the box, with zero configuration needed.

Introduction

Adapter is a function that is responsible for communication with the server. The default adapter is used to communicate with the REST server. However, there is nothing to prevent you from changing this and creating the adapter you need. Thanks to event communication, you can set your own adapter as you wish.

By default, the adapter is responsible for requests, but its role is very significant for many other elements – such as tracking the progress of requests, listening for cancellation, and mapping payloads and headers. It also applies to all the interceptors in the requesting lifecycle.

caution

If there is no XHR in the window object or the XHR object is a polyfill in your environment, you’ll have to install the npm package xmlhttprequest and set it on the window object. Otherwise we will use the node http module.


Preview

adapter(request, requestId, DO_NOT_USE)


Purpose

  • Requests handler for client dispatchers
  • Provides flexibility via handler changeability