saqueib
4 days ago
36
0
Nova

Add axios interceptor on nova requests

Posted 4 days ago by saqueib

I there any way I can add interceptor for axios used in laravel nova. I have long-form I need to focus on the first error field if there is some validation error.

I already have some route beforeach hook running fine


// this is working fine
Nova.booting((Vue, router, store) => {
router.beforeEach((to, from, next) => {
    ...
    next()
})

// Add a response interceptor
axios.interceptors.response.use(function (response) {
    return response;
}, function (error) {
    // Do something with response error
    // NOT LOGING ANYTHING IN CONSOLE
    console.log(error.response)
    return Promise.reject(error);
});

I also can't handle the exception from app/Exceptions/Handler.php

public function render($request, Exception $exception)
{
    // nothing is dumped on validation error
    dd($exception);

    return parent::render($request, $exception);
}

I am using Laravel 5.8 and Nova v2.3.0

Please sign in or create an account to participate in this conversation.