1.1.0 • Published 6 years ago

async-handler-middleware v1.1.0

Weekly downloads
2
License
ISC
Repository
github
Last release
6 years ago

Simple middleware based on express-async-handler. This package is meant to be used on the front-end. It handles exceptions inside of asynchronus functions and logs them to the console.

Installation

npm install async-handler-middleware

Usage:

An example of async-handler-middleware being used inside a thunk.

import asyncHandler from 'async-handler-middleware'

export const fetchProducts = () => asyncHandler(async (dispatch) => { const response = await axios.get('/api/products') dispatch(getProducts(response.data)) })