0

i have a list and i need to send requet for delete item in nodejs and mongo , but i have a problem with request .

for send delete request i use the module method-override .

when i send the request it show me this error :

<form method="POST" action="/admin/course/<%- course._id %>?_method=DELETE">
                    <input type="hidden" name="_method" value="delete">
                   <button type="submit">
                    <a

                    class="btn-floating btn-small waves-effect waves-light red"
                    ><i class="material-icons">edit</i></a
                  >
                   </button> 
</form>

and in the js file i config that :

        app.use(methodOverride('_method'));

but it show me this error :

Cannot DELETE /admin/course/5eeb5b6afa7d0081e93d56d6

and this the route for delete :

admin =>

router.use('/admin',adminAuthntication.Handler, adminRouter);

admin =>

router.use('/course',courseRouter);

course =>

router.delete('/:id', courseController.Delete);

now whats the problem ? how can i solve this problem ???

1 Answer 1

2

I used with full path at router and it works fine.

router.delete("/admin/course/:id", (request, response) => {
    const courseId = request.params.id;
Sign up to request clarification or add additional context in comments.

Comments

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.