serverSide data from await function() ?
serverSide data from await function() ?

I want to source table data from an asynchronous javascript function that calls a remote REST Api. The Api accepts limit and offset request parameters but they are different from DataTable's draw/start/length (etc) request parameters. The Api returns data that I will need to reformat to match DataTable's draw/recordsTotal/recordsFiltered response parameters. So I will need to catch and modify outgoing and incoming Request and Response data.
So my question is this: Can I substitute DataTable's ajax method with something like
data: await api.getData(params) ?
This question has an accepted answers - jump to answer
Answers
Yes - assuming you are building the DataTable inside an
async
function, then that will work just fine since it will wait for the response fromapi.getData()
which is presumably JSON.Allan
Thank you allan! It took me a little while to figure it out, but if you put your await function inside DataTable's ajax: property then trigger callback with the final data - it works!