How to test node.js editor api via postman?

How to test node.js editor api via postman?

CapamaniaCapamania Posts: 229Questions: 79Answers: 5

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 ..

Answers

  • CapamaniaCapamania Posts: 229Questions: 79Answers: 5

    ... 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 ...

    ....
    await editor.process(getBody);
    res.json(editor.data());
    
  • kthorngrenkthorngren Posts: 20,255Questions: 26Answers: 4,761

    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

  • CapamaniaCapamania Posts: 229Questions: 79Answers: 5

    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 ...

  • allanallan Posts: 61,627Questions: 1Answers: 10,090 Site admin

    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

This discussion has been closed.