问题解决,CURD操作问题是Content-Type: application/json没加
This commit is contained in:
parent
a91b2dad1f
commit
9d4944f7ca
|
|
@ -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.'
|
||||
|
|
|
|||
14
test.http
14
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"
|
||||
}
|
||||
Loading…
Reference in New Issue