Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- export const checkLoginCredentials = (username, password) => {
- let data = {username: username, password: password}
- fetch('/authenticate', {
- body: JSON.stringify(data),
- headers: {
- 'Content-Type': 'application/json'
- },
- method: 'POST'
- }).then(response => response.json()).then(responseJson => console.log(responseJson))}
- export const checkLoginCredentials = (username, password) => {
- return (dispatch) => {
- dispatch({ type: 'FIND_USER'});
- let data = {username: username, password: password}
- return fetch('/authenticate', {
- body: JSON.stringify(data),
- headers: {
- 'Content-Type': 'application/json'
- },
- method: 'POST'
- }).then(response => response.json()).then(responseJson => dispatch({ type: 'AUTHENTICATE', payload: responseJson }))}}
- import { combineReducers, createStore, applyMiddleware, compose } from 'redux'
- import userReducer from './userReducer'
- import gameReducer from './gameReducer'
- import thunk from 'redux-thunk';
- // we wrap store in a function for testing purposes
- const composeEnhancers =
- typeof window === 'object' && window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ ?
- window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__({
- // Specify extension’s options like name, actionsBlacklist,
- actionsCreators, serialize...
- }) : compose;
- const enhancer = composeEnhancers(
- applyMiddleware(thunk),
- // other store enhancers if any
- );
- const rootReducer = combineReducers({
- user: userReducer,
- game: gameReducer})
- export const configureStore = () => {
- return createStore(rootReducer, enhancer);}
Add Comment
Please, Sign In to add comment