beccaccino-v2
TypeScript icon, indicating that this package has built-in type declarations

2.2.2 • Public • Published

Beccaccino

Build Status Coverage Status PRs Welcome GitHub issues Maintenance

Beccaccino is an easy, sexy, reliable, framework agnostic http client for redux that is blazing beccaccino fast!

Beccaccino is meant to be used both with Node.js and web applications (React, Vue, ...)

Getting Started

yarn add beccaccino

Import the factory for building the client:

> const {
    Beccaccino,
    beccaccinoMiddleware, 
    beccaccinoReducer, 
    BECCACCINO_REDUCER_NAME, 
    resultSelector 
  } = require('beccaccino');

Configure the client with endpoints:

> const endpoints = [{ name: 'getBeers', path: '/v2/beers/:id', method: 'get' }/*, other endpoints ...*/]
> const client = Beccaccino.configure({ baseURL: 'https://api.punkapi.com' }, endpoints);

Go get some beer:

// dispatch redux action
> const { createStore, applyMiddleware, combineReducers } = require('redux');
> const store = createStore(
    combineReducers({
      [BECCACCINO_REDUCER_NAME]: beccaccinoReducer,
    }),
    {},
    applyMiddleware(beccaccinoMiddleware),
  );
> store.dispatch(client.getBeers({ urlParams: { id: 1 } }))
> resultSelector({ state: store.getState(), endpointName: 'getBeers', limit: -1})
[ [ { id: 1,
      name: 'Buzz',
      tagline: 'A Real Bitter Experience.',
      first_brewed: '09/2007',
      description:
       'A light, crisp and bitter IPA brewed with English and American hops. A small batch brewed only once.',
      image_url: 'https://images.punkapi.com/v2/keg.png',
      abv: 4.5,
      ibu: 60,
      target_fg: 1010,
      target_og: 1044,
      ebc: 20,
      srm: 10,
      ph: 4.4,
      attenuation_level: 75,
      volume: [Object],
      boil_volume: [Object],
      method: [Object],
      ingredients: [Object],
      food_pairing: [Array],
      brewers_tips:
       'The earthy and floral aromas from the hops can be overpowering. Drop a little Cascade in at the end of the boil to lift the profile with a bit of citrus.',
      contributed_by: 'Sam Mason <samjbmason>' } ] ]

// just get some beer!
> client.getBeers({ urlParams: { id: 1 } }).execAsync.then(beer => console.log('Here\'s your beer! ', beer)

Package Sidebar

Install

npm i beccaccino-v2

Weekly Downloads

7

Version

2.2.2

License

MIT

Unpacked Size

88.8 kB

Total Files

17

Last publish

Collaborators

  • renzodas