Pattern for storing response payload Pinia store? #1468
Unanswered
brandonleichty
asked this question in
Help and Questions
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello all 👋
I have a question around storing data from a response payload in state—and am wondering if there are any preferred / recommended patterns for this.
The first pattern (that I've seen a lot), creates state for each possible property in the API response payload like this:
The second pattern (that I've been personally using) looks more like this:
In this second scenario I give the entire
user
state to the Vue template—and let it do with it as it wants. Example:<div> {{ user.badgeNumber }} </div>
.My question: Is there a preferred Vue pattern for this? As I often see Pinia/Vuex stores that are massive because they have a piece of state for each and every property on the response payload — vs just storing the entire response.
Beta Was this translation helpful? Give feedback.
All reactions