Any way to swap out the "ajax" object for a custom object/function?

Any way to swap out the "ajax" object for a custom object/function?

totallyplandomtotallyplandom Posts: 27Questions: 1Answers: 1

I'm currently writing a VueJS application that includes some DataTables. The basic tables work fine when the server requires no "Authorization". However, as you can imagine, most data resources in the app require some sort of auth. That said, I'm currently using Axios for all other HTTP needs. Is there any way to "swap" the DataTables ajax object (on a per-instance basis) for another object/function (i.e. Axios)?

NOTE: I realize DataTables supposedly supports header manipulation, but everything I see points to "ajax.data" without any details or examples. Also, replacing the ajax object outright would work nicely with my current, already-authorized Axios setup.

This question has an accepted answers - jump to answer

Answers

  • totallyplandomtotallyplandom Posts: 27Questions: 1Answers: 1
    Answer ✓

    Ended up using the following:

    "ajax": {
            'url': 'api/projects',
            'headers': self.$http.defaults.headers.common
      },
    

    This basically copied the pre-set headers from the VueJS "global" axios instance.

  • allanallan Posts: 63,195Questions: 1Answers: 10,412 Site admin

    Looks good - thanks for posting back!

    Allan

This discussion has been closed.