From 9d4944f7ca4171e95e738a17d88470178da91e67 Mon Sep 17 00:00:00 2001 From: "suguo.yao" Date: Wed, 18 Sep 2024 21:27:20 +0800 Subject: [PATCH] =?UTF-8?q?=E9=97=AE=E9=A2=98=E8=A7=A3=E5=86=B3=EF=BC=8CCU?= =?UTF-8?q?RD=E6=93=8D=E4=BD=9C=E9=97=AE=E9=A2=98=E6=98=AFContent-Type:=20?= =?UTF-8?q?application/json=E6=B2=A1=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- handler/employee.js | 4 +++- test.http | 14 +++++++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/handler/employee.js b/handler/employee.js index 8aef1fc..9b48f0c 100644 --- a/handler/employee.js +++ b/handler/employee.js @@ -15,6 +15,7 @@ const list=(req,res,next)=>{ } const detail = (req,res,next)=>{ + console.log(req.body) let employeeID=req.body.employeeID Employee.findById(employeeID) .then(response=>{ @@ -23,6 +24,7 @@ const detail = (req,res,next)=>{ }) }) .catch(err=>{ + console.log(err) res.json({ message: 'An error Occured!' }) @@ -76,7 +78,7 @@ const update=(req,res,next)=>{ const destroy=(req,res,next)=>{ let employeeID=req.body.employeeID - Employee.findByIdAndDelete({"_id": ObjectId( employeeID)}) + Employee.findByIdAndDelete( employeeID) .then(()=>{ res.json({ message: 'Employee deleted successfully.' diff --git a/test.http b/test.http index 2d6cdfe..593642a 100644 --- a/test.http +++ b/test.http @@ -2,14 +2,20 @@ ### POST {{url}}/employee/detail HTTP/1.1 +Content-Type: application/json { - "employeeID": "66e99aca14f420ccd5209104" + "employeeID": "66e99c327dcae1c68f763366" } ### GET {{url}}/employee/list HTTP/1.1 +### +curl --request GET \ + --url http://localhost:8080/api/employee/list \ + --header 'user-agent: vscode-restclient' + ### POST {{url}}/employee/create HTTP/1.1 Content-Type: application/json @@ -24,9 +30,10 @@ Content-Type: application/json ### POST {{url}}/employee/update HTTP/1.1 +Content-Type: application/json { - "employeeID": "66e98e9249b0ceb1e0208b6e", + "employeeID": "66e99c327dcae1c68f763366", "name": "kerry doe", "designation": "fremale", "email": "sdfs@s22df.com", @@ -36,7 +43,8 @@ POST {{url}}/employee/update HTTP/1.1 ### POST {{url}}/employee/delete HTTP/1.1 +Content-Type: application/json { - "employeeID": "66e99c327dcae1c68f763366" + "employeeID": "66e996dfc0f1d788626a2102" } \ No newline at end of file