Software zum Installieren eines Smart-Mirror Frameworks , zum Nutzen von hochschulrelevanten Informationen, auf einem Raspberry-Pi.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

fetch-node.js 1.1KB

123456789101112131415161718192021222324252627282930313233343536
  1. 'use strict';
  2. var fetch = require('node-fetch');
  3. function wrapFetchForNode(fetch) {
  4. // Support schemaless URIs on the server for parity with the browser.
  5. // https://github.com/matthew-andrews/isomorphic-fetch/pull/10
  6. return function (u, options) {
  7. if (typeof u === 'string' && u.slice(0, 2) === '//') {
  8. return fetch('https:' + u, options);
  9. }
  10. return fetch(u, options);
  11. };
  12. }
  13. module.exports = function (context) {
  14. // Support webpack module import weirdness.
  15. var fetchFn = fetch.default ? fetch.default : fetch;
  16. // This modifies the global `node-fetch` object, which isn't great, since
  17. // different callers to `fetch-ponyfill` which pass a different Promise
  18. // implementation would each expect to have their implementation used. But,
  19. // given the way `node-fetch` is implemented, this is the only way to make
  20. // it work at all.
  21. if (context && context.Promise) {
  22. fetchFn.Promise = context.Promise;
  23. }
  24. return {
  25. fetch: wrapFetchForNode(fetchFn),
  26. Headers: fetch.Headers,
  27. Request: fetch.Request,
  28. Response: fetch.Response
  29. };
  30. };