Added required fields missing message for POST
This commit is contained in:
parent
251f52a726
commit
2dcbc472ec
@ -165,7 +165,7 @@ const ENDPOINTDATA=[
|
|||||||
function CreateDynamicEndpoints() {
|
function CreateDynamicEndpoints() {
|
||||||
ENDPOINTDATA.map((endpoint)=>{
|
ENDPOINTDATA.map((endpoint)=>{
|
||||||
app.get("/"+endpoint.endpoint,(req,res)=>{
|
app.get("/"+endpoint.endpoint,(req,res)=>{
|
||||||
db.query('select * from '+endpoint.endpoint)
|
db.query('select * from '+endpoint.endpoint+" order by id desc")
|
||||||
.then((data)=>{
|
.then((data)=>{
|
||||||
res.status(200).json({fields:data.fields,rows:data.rows})
|
res.status(200).json({fields:data.fields,rows:data.rows})
|
||||||
})
|
})
|
||||||
@ -184,7 +184,7 @@ function CreateDynamicEndpoints() {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
if (!allExist) {
|
if (!allExist) {
|
||||||
res.status(300).send("Invalid query!")
|
res.status(300).send("Required fields are: "+endpoint.requiredfields.filter((field)=>!(field in req.body)).join(','))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user