Started learning axios and I’m loving it!
Quick question, could not find an answer for it, maybe there is non.
In jQuery ajax there is a method called ajaxComplete, I was wandering if there is an equivalent in axios?
Started learning axios and I’m loving it!
Quick question, could not find an answer for it, maybe there is non.
In jQuery ajax there is a method called ajaxComplete, I was wandering if there is an equivalent in axios?
2
Answers
axios uses promises. You can use
Check out how js promises work if you do not have a basic knowledge https://web.dev/promises/
For global handling axios event this may help https://auralinna.blog/post/2019/global-http-request-and-response-handling-with-the-axios-interceptor/
No there is not. jQuery’s
$.ajax
has a function build in where it fires an event when a request has been finished. This is theajaxComplete
event.Axios does not have such behavior, but you could build your own with the
CustomEvent
interface. Or / and assume that there is a methodaxiosSuccess
on thedocument
and call that.And then listen for your own event on the document.