How to use the fetch-ponyfill function in fetch-ponyfill

To help you get started, we’ve selected a few fetch-ponyfill 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 bsdavidson / trimetric / web / src / index.jsx View on Github external
import "whatwg-fetch";
import fetchPonyfill from "fetch-ponyfill";
import ReactDOM from "react-dom";
import {BrowserRouter} from "react-router-dom";

import {render} from "./router";
import {Trimet} from "./data";
import {store} from "./store";

const trimet = new Trimet(store, fetchPonyfill().fetch);
trimet.start();

window.addEventListener("load", () => {
  ReactDOM.render(
    render(store, trimet.handleStopChange, {Router: BrowserRouter}),
    document.getElementById("app")
  );
});
github chatch / stellarexplorer / src / components / shared / BackendResourceBadgeButton.js View on Github external
import React from 'react'
import PropTypes from 'prop-types'
import CopyToClipboard from 'react-copy-to-clipboard'
import JSONPretty from 'react-json-pretty'
import Button from 'react-bootstrap/lib/Button'
import Modal from 'react-bootstrap/lib/Modal'

import NewWindowIcon from '../shared/NewWindowIcon'
import {withSpinner} from '../shared/Spinner'

import FetchPonyfill from 'fetch-ponyfill'
const fetch = FetchPonyfill().fetch

/**
 * Button that reveals a backend resouce at 'url' when clicked.
 *
 * Used to show the underlying JSON that a view was rendered with OR for
 * showing a related resource, eg. an anchor's server.toml file.
 */
const BackendResourceBadgeButton = ({handleClickFn, label, url}) => (
  <a href="{url}">
    {label}
  </a>
)
github bigchaindb / js-bigchaindb-driver / src / baseRequest.js View on Github external
import { Promise } from 'es6-promise'
import fetchPonyfill from 'fetch-ponyfill'
import { vsprintf } from 'sprintf-js'

import formatText from './format_text'

import stringifyAsQueryParam from './stringify_as_query_param'


const fetch = fetchPonyfill(Promise)


/**
 * imported from https://github.com/bigchaindb/js-utility-belt/
 *
 * Global fetch wrapper that adds some basic error handling and ease of use enhancements.
 * Considers any non-2xx response as an error.
 *
 * For more information on fetch, see https://developer.mozilla.org/en-US/docs/Web/API/GlobalFetch/fetch.
 *
 * Expects fetch to already be available (either in a ES6 environment, bundled through webpack, or
 * injected through a polyfill).
 *
 * @param  {string}  url    Url to request. Can be specified as a sprintf format string (see
 *                          https://github.com/alexei/sprintf.js) that will be resolved using
 *                          `config.urlTemplateSpec`.
github chatch / stellarexplorer / src / components / shared / LumensRates.js View on Github external
import React from 'react'
import PropTypes from 'prop-types'
import FetchPonyfill from 'fetch-ponyfill'
const fetch = FetchPonyfill().fetch

const FEED_URL = 'https://api.coinmarketcap.com/v1/ticker/stellar/'
const UPDATE_INTERVAL = 5 * 60 * 1000

class LumensRatesContainer extends React.PureComponent {
  componentDidMount() {
    this.updatePrice()
    this.intervalId = setInterval(
      () => this.updatePrice.bind(this),
      UPDATE_INTERVAL
    )
  }

  componentWillUnmount() {
    clearInterval(this.intervalId)
  }
github yanni4night / v2ex-preact / src / action / index.js View on Github external
* index.js
 *
 * changelog
 * 2016-09-08[09:07:10]:revised
 *
 * @author yanni4night@gmail.com
 * @version 0.1.0
 * @since 0.1.0
 */
'use strict';
import * as ACTION_TYPES from '../constant/action-types';
import {push, goBack} from 'react-router-redux';
import fetchPonyfill from 'fetch-ponyfill';
import Promise from 'bluebird';

const {fetch} = fetchPonyfill(Promise);

export const loadHot = () => {
    return (dispatch, getState) => {
        const state = getState();
        if (state.hot && state.hot.length) {
            return;
        } else {
            fetch('/api/topics/hot.json', {
                mode: 'no-cors',
                headers: {
                    'Accept': 'application/json',
                    'Content-Type': 'application/json'
                }
            }).then(response => response.json()).then(hot => {
                dispatch({
                    type: ACTION_TYPES.ACTION_LOAD_HOT,

fetch-ponyfill

A ponyfill (doesn't overwrite the native fetch) for the Fetch specification https://fetch.spec.whatwg.org.

MIT
Latest version published 3 years ago

Package Health Score

61 / 100
Full package analysis

Popular fetch-ponyfill functions