Skip to content

Instantly share code, notes, and snippets.

@MeetMartin
Created April 16, 2019 09:10
Show Gist options
  • Save MeetMartin/98b9eb2f9f0b056ad15c16c7b0c87150 to your computer and use it in GitHub Desktop.
Save MeetMartin/98b9eb2f9f0b056ad15c16c7b0c87150 to your computer and use it in GitHub Desktop.
// src/store/middleware.js
import match from 'conditional-expression';
import axios from 'axios';
import {types} from './reducers';
export const applyMiddleware = dispatch => action =>
dispatch(action) ||
match(action.type)
.equals(types.TRIGGER_ACTION).then(() => {
axios.get('api/v1/query')
.then(serverResponse => dispatch({type: types.DIFFERENT_ACTION, payload: serverResponse.data.response}))
.catch(error => console.log('hups');
})
.else(null);
@rafaellucio
Copy link

In line 13, do you don't close parentheses on catch statement

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment