How to use the fetch-h2.fetch function in fetch-h2

To help you get started, we’ve selected a few fetch-h2 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github bevry / boundation / source / base.js View on Github external
async function download(opts) {
	try {
		if (typeof opts === 'string') opts = { url: opts }
		const response = await fetch(opts.url, {})
		let data = await response.text()
		const file =
			opts.file || pathUtil.basename(urlUtil.parse(opts.url).pathname)
		if (await exists(file)) {
			if (opts.overwrite === false) {
				return Promise.resolve()
			}
			const localData = (await read(file)).toString()
			const localLines = localData.split('\n')
			const localCustomIndex = localLines.findIndex(line =>
				/^# CUSTOM/i.test(line)
			)
			if (localCustomIndex !== -1) {
				const remoteLines = data.split('\n')
				const remoteCustomIndex = remoteLines.findIndex(line =>
					/^# CUSTOM/i.test(line)
github bevry / boundation / source / get-github-commit.js View on Github external
async function getGithubCommit(slug, fallback = 'master') {
	const url = `${ghapi}/repos/${slug}/commits?${githubQueryString}`
	try {
		const response = await fetch(url, {
			headers: {
				Accept: 'application/vnd.github.v3+json'
			}
		})
		if (response.status < 200 || response.status >= 300) {
			throw await response.text()
		}
		const result = await response.json()
		if (result.message) {
			throw new Error(result.message + '\n' + url)
		}
		if (!result[0] || !result[0].sha) {
			return fatal(
				new Error(`${url} did not return the expected result`),
				result
			)
github bevry / boundation / source / get-node.js View on Github external
async function getNodeLTSVersions() {
	const url =
		'https://raw.githubusercontent.com/nodejs/Release/master/schedule.json'
	try {
		const response = await fetch(url)
		const json = await response.json()
		const lts = Object.entries(json)
		return lts
	} catch (err) {
		throw new Errlop(`failed to fetch node.js LTS releases from ${url}`, err)
	}
}
async function getMinimumNodeLTSVersion() {

fetch-h2

HTTP/1+2 Fetch API client for Node.js

MIT
Latest version published 2 years ago

Package Health Score

50 / 100
Full package analysis