Created
April 16, 2019 09:10
-
-
Save MeetMartin/98b9eb2f9f0b056ad15c16c7b0c87150 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In line 13, do you don't close parentheses on catch statement