Comments (7)
I am noting that vuex-crud calls error handlers from inside mutations (e.g. onFetchListError).
As far as I understand it, dispatching actions from inside mutation goes against the vuex design principle.
So, I imagine, the way one should handle errors is to catch them inside components that call upon the store. E.g.
this.$store.dispatch('foo/fetchList')
.then(function() { /* ... */ })
.catch(function(parsedError) { /* ... dispatch actions to handle errors ... */ })
from vuex-crud.
Hey @martinhbramwell @k8n,
sorry for my late reply, but I was on holiday without my laptop :-).
onFetchListError
, onFetchListSuccess
are actually not meant to be an error handlers, but rather a simple callbacks to modify the store in a custom way.
And I agree with @k8n that you should handle errors using promises on your component level
from vuex-crud.
I will update the documentation, so it's more clear that there should be no side-effects in onFetchListError
callbacks
from vuex-crud.
My requirements include keeping the user's browser console free of any errors or warnings.
I took your example and replaced those lines with
onFetchArticles() {
LG(' * * Try to fetch articles * *');
this.fetchArticles()
.then(() => { LG(' * * Fetched articles * *'); })
.catch((e) => {
LG(`*** Error while fetching articles :: ${e}***`);
});
},
When logged out and clicking Fetch articles
I see :
* * Try to fetch articles * *
GET ...myserver/api/articles 401 (Unauthorized) . . . xhr.js?ec6c:178`
*** Error while fetching articles :: Error: Request failed with status code 401***`
Where GET ...myserver/api/articles 401 (Unauthorized) . . . xhr.js?ec6c:178 is a big red line!
How can I completely clean up the console?
from vuex-crud.
@martinhbramwell I think those errors comes from default server logging see: axios/axios#599
I am really not sure if we can do anything about it.
from vuex-crud.
from vuex-crud.
Right! Understood. Thanks for looking into it and thanks for clarifying.
from vuex-crud.
Related Issues (20)
- How to call getter from parseList()? HOT 2
- dispatch action on `onFetchListSuccess` HOT 2
- state.list is not being updated when CREATE method is used HOT 2
- How to use it with nuxt's axios-module ? HOT 4
- Created entry not being added to the list HOT 1
- react to request success/error with actions
- Pagination HOT 4
- defaultClient export HOT 1
- Handle empty responses on create/update gracefully HOT 1
- entities & list aren't updated after re-run fetchList
- Maximum call stack size exceeded
- Request header not set when using with @nuxtjs/auth
- A way to change/namespace actions added to modules (conflicts with other libraries)
- customUrlFn needs access to store
- how do I clear list from outside of vuex-crud?
- how to add query string to fetch method
- Getting Uncaught (in promise) TypeError: Cannot read property 'toString' of undefined HOT 2
- Use spread operator on initial state.
- This project is a little inactive, is there something better I'm missing?
- Does last version support Vue 3? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vuex-crud.