You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

fetch-beacon

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fetch-beacon

tiny HTTP client that implements sendBeacon API

0.0.3
latest
Source
npmnpm
Version published
Maintainers
1
Created
Source

fetch-beacon

A tiny HTTP client that implements sendBeacon API

Why fetch-beacon

WARN: You should not use it besides analytics and diagnostics needs

Install

$ npm install fetch-beacon

Usage

import beacon from 'fetch-beacon';

(async () => {
	const resp = await beacon('https://example.com', {json: {foo: true}});
	console.log(resp.json());
	//=> `{data: '🦄'}`
})();

API

beacon(input, [options])

Same as fetch, except folloing option.

fetch-beacon will cache the failed request when get below status code or TimeoutError and retry it when document load again.

Status codes: 408 413 429 500 502 503 504

options.timeout

Type: number, Default: 10000

options.keepalive

Type: boolean, Default: true

#### options.retry Type: number, Default: 2

Retry failed request if get one of following code.

beacon.TimeoutError

The error thrown when the request times out.

Keywords

http

FAQs

Package last updated on 11 Mar 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts