Anton Kosykh
1 min readMar 18, 2018

--

I always thought that vuex is not the place to write API requests inside. I’ll try to explain why

Vuex is a state management, not API. It should only care about data and its changes

When you use actions with API requests and handle ’em in vuex — vuex cares about API.

But what if I call API request from another part of application, not from vuex (not via vuex)? Data becomes outdated

That’s why I think it should be vice versa and why API layer is needed— API layer cares about API requests (suddenly) and updates store, if it’s needed. Store stay clean and doesn’t care about outer world

--

--

Anton Kosykh
Anton Kosykh

Written by Anton Kosykh

— Stricty pants nerd that sounds like total dork (according to one of the readers) — Also YOLO JavaScript Engineer

Responses (1)