0.2.1 • Published 1 year ago

stdfetch v0.2.1

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

stdfetch

A full implementation of DOM fetch API for Node.js

Installation

npm install stdfetch

Usage

import { fetch } from "stdfetch";

const response = await fetch("https://example.com/file.txt");
console.log(await response.text());
import { fetch, Request } from "stdfetch";

const response = await fetch(new Request("https://example.com/binary-file", {
	method: "GET",
	headers: {
		"User-Agent": ""
	}
}));

if (response.ok) {
	const headers = response.headers;
	const buffer = await response.arrayBuffer();
}

Fetch local file

const response = await fetch("file:///directory/file.txt");

Fetch from data URL

const response = await fetch("data:text/plain;base64,SGVsbG8gV29ybGQK");

Load JavaScript URL

const response = await fetch("javascript:console.log('Hello World');");
0.2.1

1 year ago

0.2.0

1 year ago

0.1.6

1 year ago

0.1.5

1 year ago

0.1.4

1 year ago

0.1.3

1 year ago

0.1.2

1 year ago

0.1.1

1 year ago

0.1.0

1 year ago