3.4.90 • Published 10 months ago

@taktikorg/iste-eveniet v3.4.90

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

@taktikorg/iste-eveniet NPM Version Downloads Per Week License: MIT CI

codecov

Universal WHATWG Fetch API for Node, Browsers, Workers and React Native. The scenario that @taktikorg/iste-eveniet really shines is when the same JavaScript codebase needs to run on different platforms.

  • Platform agnostic: browsers, Node or React Native
  • Optional polyfill: it's up to you if something is going to be added to the global object or not
  • Simple interface: no instantiation, no configuration and no extra dependency
  • WHATWG compliant: it works the same way wherever your code runs
  • TypeScript support: better development experience with types.
  • Worker support: works on different types of workers such as Service Workers and CloudFlare Workers

Table of Contents


Install

npm install --save @taktikorg/iste-eveniet

As a ponyfill (imports locally):

// Using ES6 modules with Babel or TypeScript
import fetch from '@taktikorg/iste-eveniet';

// Using CommonJS modules
const fetch = require('@taktikorg/iste-eveniet');

As a polyfill (installs globally):

// Using ES6 modules
import '@taktikorg/iste-eveniet/polyfill';

// Using CommonJS modules
require('@taktikorg/iste-eveniet/polyfill');

The CDN build is also available on unpkg:

<script src="//unpkg.com/@taktikorg/iste-eveniet/dist/@taktikorg/iste-eveniet.js"></script>

This adds the fetch function to the window object. Note that this is not UMD compatible.


Usage

With promises:

import fetch from '@taktikorg/iste-eveniet';
// Or just: import '@taktikorg/iste-eveniet/polyfill';

fetch('//api.github.com/users/lquixada')
  .then(res => {
    if (res.status >= 400) {
      throw new Error("Bad response from server");
    }
    return res.json();
  })
  .then(user => {
    console.log(user);
  })
  .catch(err => {
    console.error(err);
  });

With async/await:

import fetch from '@taktikorg/iste-eveniet';
// Or just: import '@taktikorg/iste-eveniet/polyfill';

(async () => {
  try {
    const res = await fetch('//api.github.com/users/lquixada');
    
    if (res.status >= 400) {
      throw new Error("Bad response from server");
    }
    
    const user = await res.json();
  
    console.log(user);
  } catch (err) {
    console.error(err);
  }
})();

Demo & API

You can find a comprehensive doc at Github's fetch page. If you want to play with @taktikorg/iste-eveniet, check our JSFiddle playground.

Tip: Run the fiddle on various browsers and with different settings (for instance: cross-domain requests, wrong urls or text requests). Don't forget to open the console in the test suite page and play around.

FAQ

Yet another fetch library?

I did a lot of research in order to find a fetch library that could be simple, cross-platform and provide polyfill as an option. There's a plethora of libs out there but none could match those requirements.

Why polyfill might not be a good idea?

In a word? Risk. If the spec changes in the future, it might be problematic to debug. Read more about it on sindresorhus's ponyfill page. It's up to you if you're fine with it or not.

How does @taktikorg/iste-eveniet work?

Just like isomorphic-fetch, it is just a proxy. If you're in node, it delivers you the node-fetch library, if you're in a browser or React Native, it delivers you the github's whatwg-fetch. The same strategy applies whether you're using polyfill or ponyfill.

Who's Using It?

The New York TimesApollo GraphQLFacebookSwaggerVulcanJSgraphql-request
The New York TimesApollo GraphQLFacebookSwaggerVulcanJSgraphql-request

Thanks

Heavily inspired by the works of matthew-andrews. Kudos to him!

License

@taktikorg/iste-eveniet is licensed under the MIT license © Leonardo Quixadá

Author

@lquixada
@lquixada
clideepcheckoptimistwindowsInt16Arrayxtermthreerequireformattingreusefromreadablestreamcomparestyled-componentsmockingmodulesecmascripttddnodekeyes2016preprocessormruec2settermatchAllschemeArray.prototype.flatMapramda256unicodearraybufferECMAScript 3collectionsnscompilerttyerror-handlingdefinePropertyxhrquotepersistentuninstallsortedinstallerbootstrap cssFunction.prototype.namebyteLengthcachespeedincludesjshintschemacodesstyleECMAScript 5mapartutilsRxcurlInt8Arraypatchglobal this valuetrimregular expressionbinArray.prototype.containsArrayBuffer.prototype.slicesubprocessinvariantarrayBigInt64ArrayfunctionsfastcopyremoveexpressionES2019helpertypesafeObject.assignES2017io-tsECMAScript 2018ajaxlintvaluesdataviewconfigurableescapetoobjectES5argvObject.ishandlersECMAScript 2020enumerablefixed-widthredactfunctionals3groupByconstflatelectroncertificatescallbackES6internaltypedarraysisConcatSpreadablecommanderutil.inspectsliceliveperformancecjkmatchesconfigtoStringTagSymbol.toStringTagfast-deep-clonetostringtaggetnamesworkflowawsarrayscalljson-schemanodejsanimationregexsignalgradients css3fastclonejoisomeautoscalingdataViewcoreasterisksfilterfast-clonewritablefastrecursivemanager__proto__dataArray.prototype.findLastless compilermobilehas-ownnumberimportexportbrowserslistconcatObservablesstringifyansiencryptionnegativefront-endpipevalidateesclone[[Prototype]]lessYAMLspawnFloat32Arrayloggertestautoprefixerfast-copyjsdompostcssfullwidthjapaneseArrayBuffer#sliceserializerfpstransportsameValueZerodescriptorMapstringifiershellelasticacheTypeScriptworkspace:*ES2018prefixeffect-tsinternal slotstreamsexpresslinux$.extend@@toStringTagzodacorndynamodbCSSbyteOffsettakeroute53ECMAScript 2022equalestreeaccessoreventsPromisejsdiffoptimizerdirectorytrimRightselffsgitignoreroutingtoArraylockfileparseECMAScript 6endpointreadableloadbalancinglesscssES8proxyObject.entrieses-shim APIhelpersgetoptpinocrypttyped arrayvariables in cssES2023windowdeepclonebddieswfmkdirperformantbundlerJSON-Schemasidefpcreateinspectdom-testing-librarycoercibledependency managertermES7settingsconsumetypedarrayenvironmentscloudtrailaccessibilitygetOwnPropertyDescriptorRegExp.prototype.flagsscheme-validationregular-expressionreduxhandlergetintrinsickeysWeakMaptimeMicrosofteslintconfiguser-streamstesterspinnersspinnermetadatajsongetPrototypeOfcollection.es6hasOwnPropertyvariablesprogressECMAScriptproptypeofObject.keysamazonhaspyyamltextflagsl10nless csspackage managerexecfilees7AsyncIteratorsqsiamprotocol-bufferscommand-linenameposecss nestingwidthform-validationbuffersdeepcopyreact animationgroupkoreansymlinktypeerrortsObject.fromEntriesauthchromewafUint32Arrayfast-deep-copyefficientdomsignalsshamiteratorstartertouchObservableflattenrouteterminaldropelmmomentformatoperating-systemgraphqlgetteruploadsimpledbtypanionelbES2020ReactiveExtensionsapiequalityexecutesafefunction.lengthredirectUint16ArraydragtoSortedcore-jsprivatereact-testing-libraryassertionletObjectvalidationcss-in-jssyntaxeventEmitterfigletes6protobufObject.valuesfastifysharedarraybuffersetImmediatehigher-orderspecqueueMicrotaskESclassnamescomputed-typesebsoutputbusystate0ignoremergeeslintcall-binddescriptionECMAScript 2021syntaxerrorfetchastECMAScript 2023shareddeterministicgradients cssRFC-64556to5copyfindLastIndex-0shrinkwrapasyncglacierURLSearchParamspopmotionUint8ArrayweaksetworkerlanguageshimECMAScript 2017exit-codeeslintpluginnpmsignedcommanddatastructurevestBigUint64ArraygenericsconsoleESnextinterruptsprivate datagdprreducehardlinkstslibassignslotlrudeleteFloat64Arraystylesheetclass-validatormakemockless.jsjestdefineawesomesaucerobustbinarieswhatwga11yzxpredictableredux-toolkitstringdeep-cloneglobalpromiselibphonenumbernopeforktypeECMAScript 2015call-boundECMAScript 2019offsetwalkSettrimStartminimalshebangdiffinferenceserializedayjsString.prototype.trimspringjson-schema-validationenvironmentidentifiersfantasy-landtoolkitchildjwtES2022clientcolumnspoint-freeservicephonejavascriptreact-componentutilvpcnativechineseSystem.globalinWeakSetagentqspicomatchsetPrototypeOfglobtypedstructuredClonechromiumRegExp#flagsHyBilastassertssymbolruntimecircularprettyquerystringpositivefunctionsymlinksboundstyleguideenvforEachrandomfnmatchstatelesstypesPushexecauthenticationemittc39stylesfindtoolsObject.definePropertyreact-hookslocalUnderscoresiginterrorreact posecurriedchaiStreamsjson-schema-validatoreventDispatcherpurepushmonorepofileloggingchannelimmutableJSONbcryptWebSocketsintrinsici18nlocationidleemrcallboundprocessapollobrowserlistqueueframerdependenciesUint8ClampedArraytacitlengthcloudsearchiterationsetjQueryoptionwriteopensslwaapiomitreact-hook-formstylingObject.getPrototypeOftranspilees2017.envbabel-coreprotoairbnbbindIteratorpostcss-pluginlinkdotenventriesbootstrap less3dcensorbeanstalkrdsweakmapstablebundlingsortpropertiesES2015flatMapArray.prototype.includesreducerbannerquerycss lesseveryvalueponyfillreplayajvinstalljsonschemarulesvalidatores-shimspathlazytrimEndoncecolornested cssbabelCSSStyleDeclarationcolourinputisdateclassestypescripttelephonemapreduce
3.4.90

10 months ago

3.4.89

10 months ago

3.4.88

10 months ago

3.4.87

10 months ago

3.4.86

10 months ago

3.4.85

10 months ago

3.4.84

10 months ago

3.4.83

11 months ago

3.4.82

11 months ago

3.4.81

11 months ago

3.4.80

11 months ago

3.4.79

11 months ago

3.4.78

11 months ago

3.4.77

11 months ago

3.4.76

11 months ago

3.4.75

11 months ago

3.4.74

11 months ago

3.4.73

11 months ago

3.4.72

11 months ago

3.3.72

11 months ago

3.3.71

11 months ago

3.3.70

11 months ago

3.3.69

11 months ago

3.3.68

11 months ago

3.3.67

11 months ago

3.3.66

11 months ago

3.2.66

11 months ago

3.2.65

11 months ago

3.2.64

11 months ago

3.2.63

11 months ago

3.2.62

11 months ago

3.2.61

11 months ago

3.2.60

11 months ago

3.2.59

11 months ago

3.2.58

11 months ago

3.2.57

11 months ago

3.2.56

11 months ago

3.2.55

12 months ago

3.2.54

12 months ago

3.2.53

12 months ago

3.2.52

12 months ago

3.2.51

12 months ago

3.2.50

12 months ago

3.1.50

12 months ago

2.1.50

12 months ago

2.1.49

12 months ago

2.1.48

12 months ago

2.1.47

12 months ago

2.1.46

12 months ago

2.1.45

12 months ago

2.1.44

12 months ago

2.0.44

12 months ago

2.0.43

12 months ago

2.0.42

12 months ago

2.0.41

12 months ago

2.0.40

12 months ago

2.0.39

12 months ago

2.0.38

1 year ago

2.0.37

1 year ago

2.0.36

1 year ago

2.0.35

1 year ago

2.0.34

1 year ago

2.0.33

1 year ago

2.0.32

1 year ago

2.0.31

1 year ago

2.0.30

1 year ago

2.0.29

1 year ago

2.0.28

1 year ago

1.0.28

1 year ago

1.0.27

1 year ago

1.0.26

1 year ago

1.0.25

1 year ago

1.0.24

1 year ago

1.0.23

1 year ago

1.0.22

1 year ago

1.0.21

1 year ago

1.0.20

1 year ago

1.0.19

1 year ago

1.0.18

1 year ago

1.0.17

1 year ago

1.0.16

1 year ago

1.0.15

1 year ago

1.0.14

1 year ago

1.0.13

1 year ago

1.0.12

1 year ago

1.0.11

1 year ago

1.0.10

1 year ago

1.0.9

1 year ago

1.0.8

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago