YAFA
YAFA (Yet Another Fetch alternative) is a super simple library that allow to "wrap" fetch requests and responses.
Request wrappers
const requestWrapper = { return } const wrappedFetch = fetch // fetch will be called with 'http://some-url-wrapped'// as first argument
A request wrapper takes every arguments given to fetch call, preceded by a callback function (named delegate
in the above example). This callback function should be called as if it was the real fetch function (i.e. with modified parameters).
const requestWrapper = { return } const anotherRequestWrapper = { return } // fetch will be called with// 'http://some-url-wrapped-wrappedAnotherTime'// as first argumentconst wrappedFetch = fetch
Response wrappers
const responseWrapper = responsereplace const newFetch = fetch // Every occurrence of 'e' has been replace// by a 'a' in the response
In response wrapper, the modified response should be returned by the wrapper.
As request wrappers, response wrappers can be chained.
const responseWrapper = responsereplaceconst responseWrapper2 = responsereplace const newFetch = fetch // Every occurrence of 'e' and 'a' has been replace// by a 'i' in the response