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

219
Views
Redux : Cannot pass nested variable to action

I need to pass suggestion._id to my action as response_id on onClick but some reason I'm receiving [object%20Object] in console. I tried response_id: suggestion._id in order to declare it first but didn't work.

Action :

export const deleteResponse = (id, response_id) => async dispatch => {
  try {
    await axios.delete(`/api/suggestions/response/${id}/${response_id}`);
    dispatch({ type: DELETE_REPONSE, payload: response_id });
    dispatch(setAlert('Review removed', 'success'));
  } catch (err) {
    dispatch({
      type: RESPONSE_ERROR,
      payload: {
        msg: err.response,
        status: err.response.status,
      },
    });
  }
};

Component in frontend:

 <Box mt='auto'>
      <Flex justifyContent={'space-between'} mb='2'>
        {suggestion._id}
        <Box my='auto'>
          {!auth.loading && user === auth.user._id && (
            <Button
              type='button'
              
              onClick={(e) =>
                deleteResponse(id, {
                  response_id: suggestion._id,
                })
              }
            >
              Remove
            </Button>
          )}
        </Box>
      </Flex>
     
    </Box>;
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

This is because you forgot to destructure, you need to do it like this:

export const deleteResponse = (id, { response_id }) => async dispatch => {
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!