0

i am developing a project using DRF and react js not delete using drf working fine but by axios.delete giving 403 error.

actions/review.js

export const deleteReview = (id) => dispatch => {
axios
    .delete(`/api/review/${id}`)
    .then(res => {
        dispatch({
            type: DELETE_REVIEW, 
            payload: id
        })
    })
    .catch(err => console.log(err))

}

reducers/review.js

case DELETE_REVIEW:
    return {
        ...state,
        review: state.review.filter(review => review.id !== action.payload)
    }

main review file

<tbody>
{ this.props.review.map(review => (
<tr key={review.id}>
    <td>{review.id}</td>
    <td>{review.city_name}</td>
    <td>{review.traveller_name}</td>
    <td>{review.traveller_review}</td>
    <td>{review.review_img}</td>
    <td><button onClick = {this.props.deleteReview.bind(this, review.id)}className="btn btn-danger btn-sm">Delete</button></td>
</tr>
</tbody>
2
  • Show us the server-side code! Because, that's where 403 response is coming from, right? Commented Jan 12, 2020 at 5:28
  • Likely duplicate of stackoverflow.com/questions/54097524/… - looks like you're missing CSRF. Commented Jan 12, 2020 at 5:53

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.