An isomorphic API proxy, which currently supports jquery on the browser and hapi on the server. This module was created to compliment Fluxapp actions and allow server and client to share the same code base.
npm install --save fluxapp-fetch
import fetch from 'fluxapp-fetch';
function handler(request, reply) {
const context = fluxApp.createContext({
fetcher: fetch('hapi', {
request: request
})
});
}
import fetch from 'fluxapp-fetch';
const context = fluxApp.createContext({
fetcher: fetch('jquery')
});
Using the above it will expose a method on our actions this.context.fetcher(options)
, for both server side and client side usage.
- url
- method
- headers
- payload
Take a look at the existing Hapi and jQuery implementations. The transport should expose a function that accepts a config object and return a function that accepts an options object.