Fetchin
Install
yarn add fetchin
Fetchin assumes that fetch()
is globally available, install isomorphic-fetch
as well (not needed for React Native).
Usage
; // make a simple get request, promise-based, returns parsed json by default (can be modified)await ; // passing params, url encoding is handled for youawait ; // https://foo?bar=123 // one base, multiple endpointsconst base = 'https://foo';await ; // https://foo/barawait ; // https://foo/baz // no need for template strings, use argsawait ; // https://foo/123await ; // https://foo/123/456 // response is not json?await ; // tweak/pass any other fetch() optsawait ; // make a simple post request, same api as get with an additional body optionawait ; // Content-Type by default is `application/json`, body is stringified, to overwrite utilize optsawait ; // need access to the raw response?await ; // returns { data, ref }