Options
All
  • Public
  • Public/Protected
  • All
Menu

Module src/core/request/engines/xhr

core/request/engines/xhr

This module provides a function that creates a request engine based on the XMLHttpRequest API. Mind, this API is developed to work in a browser — node.js support only for tests.

Synopsis

  • The engine is used by default in a browser if it doesn't support AbortController.
  • The engine partly supports response streaming (only total/loaded fields without data).
  • The engine provides a bunch of internal events.

Example

import xhrEngine from 'core/request/engines/xhr';

const req = req('/search', {engine: xhrEngine}).then(({response}) => {
console.log(response.decode());
});

req.emitter.on('progress', () => {
// ..
});

req.emitter.on('upload.progress', () => {
// ..
});

Index

Variables

Variables

default: RequestEngine = ...

Creates request by using XMLHttpRequest with the specified parameters and returns a promise

param params