laravel / nova-issues

556 stars 34 forks source link

`Nova.request()` auto handle message #6352

Closed bocanhcam closed 7 months ago

bocanhcam commented 7 months ago

I'm using custom-tools and I have a simple function using Nova.request().


async getRoom() {
            const apiUrl = '/api/room';

            this.loading = true;
            await Nova.request().get(apiUrl)
                .then(response => {
                    // To do
                })
},

The thing is Nova auto shows a toast error message when the API gets error 500. Screenshot from 2024-04-17 17-29-56

If I use Axios or change the HTTP response in the back-end when error then the message will not be shown. Such as: message => $e->getMessage() to xxx => $e->getMessage()

Is this a feature or does my code have bugs? in this custom tool, I don't use any Nova.error.

And seems like it only handles error 500. When error 404 I don't see it show toast error.

crynobone commented 7 months ago

That's the expected behavior since setupAxios() would register all the response interceptors. You should use your own Axios instance to avoid this if you need it.