How to use the whatwg-fetch.Headers function in whatwg-fetch

To help you get started, we’ve selected a few whatwg-fetch 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 ALF-er / reactjs-and-cutting-edge-stack / src / app / utils / GITHUBAPIUtils.js View on Github external
async search(term) {
		const headers = new Headers();
		headers.append("Accept", "application/json");
		headers.append("Content-Type",  "application/json");

		const query = JSON.stringify({ q: term });

		let response = await fetch(
			"https://api.github.com/search/repositories?q=" + encodeURIComponent(term),
			{
				method: "GET",
				headers
			}
		);

		if (response.status < 200 || response.status >= 300) {
			throw new Error(response.statusText);
		}

whatwg-fetch

A window.fetch polyfill.

MIT
Latest version published 4 months ago

Package Health Score

93 / 100
Full package analysis