Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Question how do I get the responseText back on my loginReducer?
- //Code below is working on the example, just some snippets, I think im close to understanding but not completely.
- //Actions:
- fetch('https://google.com')
- .then((response) => response.text())
- .then((responseText) => {
- console.log(responseText);
- dispatch(actionsCreators.succesLogin(responseText));
- //Const actionsCreators
- //how does 'data' or any other type of variable work here? related to reducers or
- succesLogin: (data: Object): Object => ({
- type: actionsTypes.SUCCES_ON_LOGIN,
- data
- }),
- //Initial State
- //Should data be part of initial state?
- const initialState = {
- isLoggedIn: false,
- waitingSymbol: false,
- error: ""
- };
- //loginReducer:
- //how to get the passed back variables here?
- const loginReducer = ( state = initialState, action ) => {
- switch (action.type) {
- case types.SUCCES_ON_LOGIN:
- return Object.assign({}, state, {
- isLoggedIn: true,
- waitingSymbol: true,
- error: "Login success"
- });
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement