2.1.1 • Published 2 years ago

beccaccino v2.1.1

Weekly downloads
7
License
MIT
Repository
github
Last release
2 years ago

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)
2.1.1

2 years ago

2.1.0

4 years ago

2.0.0

5 years ago

1.1.3

5 years ago

1.1.2

5 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago

0.1.4

6 years ago

0.1.3

6 years ago

0.1.2

6 years ago

0.1.1

6 years ago

0.1.0

6 years ago