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

195
Views
How do I send a DELETE request with axios?

How do I send a DELETE request with axios containing data?

My backend is not picking up the data, and so I'm not sure if this is because It is not possible to send data with axios delete, or if I structured the request wrong.

My Data:

     const deleteTrack = (e) =>{ e.preventDefault()
            {
                
                dispatch(
                    deleteTracks({
                    'user_id':userInfo.id,
                    'trackitem_id':trackitem._id,
                }
                
                ))
                 window.location.reload();
            }
    
        }

My request:

export const deleteTracks = (track) => async(dispatch,getState) => {
    console.log(track)
    try{
        dispatch({
            type:TRACK_DELETE_REQUEST,
        }) 

        const  {
            userLogin: {userInfo},
            } = getState()
        const config = {
            headers:{
                'Content-type':'application/json',
                Authorization:`Bearer ${userInfo.token}`
            }
        }
        //Maybe your not supposed to send data
        const { data } = await axios.delete(`/api/deletetrackitem/`,config,track)
        dispatch({
            type:TRACK_DELETE_SUCCESS,
            payload:data,
        })

    }
    catch(error){
        dispatch({type:TRACK_DELETE_FAIL,
            payload:error.response && error.response.data.detail ? error.response.data.detail : error.message,
    })
    }
    }

Thanks

about 4 years ago · Juan Pablo Isaza
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!