While attempting to create a basic "to-do list" using HTML requests, I encountered an issue with the PATCH request. Instead of redirecting to "/", it redirected to "/posts/2" and displayed the message "Cannot POST /posts/2", without updating the array element as expected.
I expected it to redirect to the home "/" page, displaying all elements including the modified one, but I am struggling to pinpoint the error in the code. Here is the snippet of the code: INDEX.JS
import express from 'express'; import bodyParser from 'body-parser'; //rest of the code... Feel free to continue rewriting the rest of the text for uniqueness!</questionbody> <exquestionbody> <div class="question"> <p>In my attempt to make an excercise, a simple "to-do list" with all of html requests. They all works fine except for the PATCH witch should redirect to "/" when actually goes to "/posts/2" and I get the "Cannot POST /posts/2" message while the array's element doesn't change.</p> <p>I was expecting it to redirect to the home "/" and show all elements with the modified one, however, I can't locate the error within the code. Below is the section of the INDEX.JS file:</p> <pre><code>import express from 'express'; import bodyParser from 'body-parser'; // Add your code here... </div> </exquestionbody> <answer1> <div class="answer" i="77681855" l="4.0" c="1702924582" a="Q2xhdWRpbyBDYXNzb2w=" ai="23058006"> <p>SOLVED! I changed <code>app.patch
toapp.post
and it works.