How to test node.js editor api via postman?
How to test node.js editor api via postman?
I'm using datatables on a node.js application. (https://editor.datatables.net/manual/nodejs/). All works fine.
Now I want to test the editor api with postman. Here I don't get back a response back. What am I missing?
If I send a POST to a route http://127.0.0.1:2001/v1/abc which normally runs the script ... and in 'Body' 'raw' & 'JSON(application/json)' of postman I'm sending this JSON ..
{
"draw": "1",
"columns": [{
"data": "name",
"name": "",
"searchable": "true",
"orderable": "true",
"search": {
"value": "",
"regex": "false"
}
}{
"data": "country",
"name": "",
"searchable": "true",
"orderable": "true",
"search": {
"value": "",
"regex": "false"
}
}, {
"data": "",
"name": "",
"searchable": "false",
"orderable": "false",
"search": {
"value": "",
"regex": "false"
}
}],
"order": [{
"column": "1",
"dir": "desc"
}],
"start": "0",
"length": "25",
"search": {
"value": "",
"regex": "false"
}
}
I would expect getting a response ... but getting a infinite ...loading ..
This discussion has been closed.
Answers
... what I need at the end is ... if somebody tries to access the route ... but no valid 'datatable node.js' format is given in the body of the POST sent to the route ... I want to send back an error res.json() ... instead of an infinite request ...
I might be missing something but the request data you are sending would be from a Datatables draw request not an Editor function. If you want to simulate Editor data then this page will show the expected behavior:
https://editor.datatables.net/manual/server#Example-data-exchanges
Kevin
mmh ... is there any way to check if the data send to the route of the node.js application is in the right form datatable expects?! If it's not in the right format I want datatable to send a error response back ... for the server not to run infinitly ...
I've no idea why that would run forever. I think you will need to add some debugging to your NodeJS script. Specifically, the first thing I would suggest is to dump out the
getBody
parameters and make sure that you are getting that at the server-side.Allan