How to use the isomorphic-fetch.Request function in isomorphic-fetch

To help you get started, we’ve selected a few isomorphic-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 ctx-core / ctx-core / packages / isomorphic-fetch / lib.ts View on Github external
import { _no__dom } from '@ctx-core/dom'
export default (
	_no__dom()
	? require('isomorphic-fetch')
	: window.fetch
) as (input:RequestInfo, init?:RequestInit)=>Promise
export const Headers:Headers = _no__dom() ? require('isomorphic-fetch').Headers : window.Headers
export const Request:Request = _no__dom() ? require('isomorphic-fetch').Request : window.Request
export const Response:Response = _no__dom() ? require('isomorphic-fetch').Response : window.Response
github ctx-core / ctx-core / packages / fetch / lib.js View on Github external
/**
 * Module wrapping the fetch http client for ctx-core
 * @module @ctx-core/fetch/lib
 */
import { sleep } from '@ctx-core/sleep';
import { _number__fibonacci } from '@ctx-core/fibonacci';
import { _no__dom } from '@ctx-core/dom';
import { throw__error } from '@ctx-core/error';
import fetch from '@ctx-core/isomorphic-fetch';
import { log } from '@ctx-core/logger';
const logPrefix = '@ctx-core/fetch';
export { fetch };
export function _headers(init) {
    return _no__dom() ? init : new window.Headers(init);
}
export const Request = _no__dom() ? require('isomorphic-fetch').Request : window.Request;
export const Response = _no__dom() ? require('isomorphic-fetch').Response : window.Response;
export function _method__fetch(ctx__fetch) {
    return (ctx__fetch.method || 'GET').toUpperCase();
}
export function _url__fetch(ctx__fetch) {
    const { url } = ctx__fetch;
    return url;
}
export async function throw__response__fetch(response) {
    log(`${logPrefix}|throw__response__fetch`);
    const error_message = await response.text();
    throw__error({
        status__http: response.status,
        error_message,
    });
}
github ctx-core / ctx-core / packages / fetch / lib.ts View on Github external
/**
 * Module wrapping the fetch http client for ctx-core
 * @module @ctx-core/fetch/lib
 */
import { sleep } from '@ctx-core/sleep'
import { _number__fibonacci } from '@ctx-core/fibonacci'
import { _no__dom } from '@ctx-core/dom'
import { throw__error } from '@ctx-core/error'
const fetch = _no__dom() ? require('isomorphic-fetch') : window.fetch
import { log } from '@ctx-core/logger'
const logPrefix = '@ctx-core/fetch'
export { fetch }
export const Headers = _no__dom() ? require('isomorphic-fetch').Headers : window.Headers
export const Request = _no__dom() ? require('isomorphic-fetch').Request : window.Request
export const Response = _no__dom() ? require('isomorphic-fetch').Response : window.Response
export function _headers(init) {
	return _no__dom() ? init : new window.Headers(init)
}
export function _method__fetch(ctx__fetch):string {
	return (ctx__fetch.method || 'GET').toUpperCase()
}
export async function throw__response__fetch(response) {
	log(`${logPrefix}|throw__response__fetch`)
	const error_message = await response.text()
	throw__error({
		status__http: response.status,
		error_message,
	})
}
export async function waitfor__backoff__fibonacci(fn, delay = 500) {