Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

69
Views
Redux not returning object

I am finding myself in a rabbit hole lol. I am making a call to gett a list of objects and the call is successful, and I can see the data getting returned back. But I am not understanding why columnDefs is not getting updated with the success data.

defaultState = {
  columnDefs: []
}

export default function MarketReducer(state = defaultState,action ){
  switch (action.type){
        case GET_MARKETING_LIST:
            return Object.assign({}, state, {
                columnDefs: [],
            });
        case GET_MARKETING_SUCCESS:
           return Object.assign({}, state, {
                columnDefs: action.payload.data.column_headers.columnDefs,
            });
        case GET_MARKETING_FAIL:
            return Object.assign({}, state,{
                error: action.error,
                columnDefs: [],
            });
        default:
        return state;
  }
}

export function getMarketingProspects() {
        return {
            type: GET_MARKETING_LIST,
            payload: {
                request: {
                    url: "/marketing/customers",
                    method: "GET"
                }
            }
        };
}

Then I have a button that is triggering getMarketingProspects(). Problem is that store is not getting updated.

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

The reason as to why it was not setting it to the store is because the actions were named different, i had to add "LIST" to success and failed, this then worked.

GET_MARKETING_LIST: GET_MARKETING_LIST_SUCCESS: GET_MARKETING_LIST_FAIL:

about 4 years ago · Juan Pablo Isaza Report

0

export function getMarketingProspects() {
  return (dispatch) => {
    dispatch({
      type: GET_MARKETING_LIST,
      payload: {
        request: {
          url: "/marketing/customers",
          method: "GET"
        }
      }
    })
  }
}

now, on the action button you should dispatch the getMarketingProspects function. Like this.

onClick={()=> useDispatch(getMarketingProspects())}
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!