From 7b5e1d3774a04c1f7c0b3cdfbbdb5884411d47bf Mon Sep 17 00:00:00 2001 From: Krish <159127686+krish2366@users.noreply.github.com> Date: Fri, 20 Sep 2024 13:16:20 +0530 Subject: [PATCH] Update Manager.jsx fixed a major bug with latest versions of products used --- Video 130/passop-mongo/src/components/Manager.jsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Video 130/passop-mongo/src/components/Manager.jsx b/Video 130/passop-mongo/src/components/Manager.jsx index e60c064a..c353546f 100644 --- a/Video 130/passop-mongo/src/components/Manager.jsx +++ b/Video 130/passop-mongo/src/components/Manager.jsx @@ -54,7 +54,9 @@ const Manager = () => { if (form.site.length > 3 && form.username.length > 3 && form.password.length > 3) { // If any such id exists in the db, delete it - await fetch("http://localhost:3000/", { method: "DELETE", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ id: form.id }) }) + if(form.id){ //if this statement is not there then it will delete one entry anyways, have to resist it that way + await fetch("http://localhost:3000/", { method: "DELETE", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ id: form.id }) }) + } setPasswordArray([...passwordArray, { ...form, id: uuidv4() }]) await fetch("http://localhost:3000/", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ ...form, id: uuidv4() }) })