Nuxtj - Best practice to load all information of users after the authentication process
up vote
0
down vote
favorite
i am not a developer but i am deploying a web application using nuxt and i have a doubt about load all information related to the users once in the application, all the information is managed by vuex. I need to load all information after the authentication process because i am showing a dashboard to the user. I have read and found the next options but i don't know where is the best practice without impact the performance of the application:
1.- Load all information in the same vuex action where the user authenticates. I have an action to validate the user and password and it creates the cookies and token sessions. I can load all information in the same action but the authentication process could be slower. With this option the load of information is executed just once.
2.- Load all information in the main/dashboard component by the fetch function consuming an vuex action (do a dispatch). It works but i am seeing that when i browse to the main/dashboard component the fetch function is always appearing. Load of information should be once after the authentication process.
3.- I also am using the nuxtserverinit to load all information when the users press F5 button or reload the web application but if i do a reload in the main/dashboard component i am seeing nuxtserverinit and fetch functions . I am duplicating resources.
I really appreciate your help.
Thanks in advance.
vue.js vuejs2 vuex nuxt.js nuxt
add a comment |
up vote
0
down vote
favorite
i am not a developer but i am deploying a web application using nuxt and i have a doubt about load all information related to the users once in the application, all the information is managed by vuex. I need to load all information after the authentication process because i am showing a dashboard to the user. I have read and found the next options but i don't know where is the best practice without impact the performance of the application:
1.- Load all information in the same vuex action where the user authenticates. I have an action to validate the user and password and it creates the cookies and token sessions. I can load all information in the same action but the authentication process could be slower. With this option the load of information is executed just once.
2.- Load all information in the main/dashboard component by the fetch function consuming an vuex action (do a dispatch). It works but i am seeing that when i browse to the main/dashboard component the fetch function is always appearing. Load of information should be once after the authentication process.
3.- I also am using the nuxtserverinit to load all information when the users press F5 button or reload the web application but if i do a reload in the main/dashboard component i am seeing nuxtserverinit and fetch functions . I am duplicating resources.
I really appreciate your help.
Thanks in advance.
vue.js vuejs2 vuex nuxt.js nuxt
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
i am not a developer but i am deploying a web application using nuxt and i have a doubt about load all information related to the users once in the application, all the information is managed by vuex. I need to load all information after the authentication process because i am showing a dashboard to the user. I have read and found the next options but i don't know where is the best practice without impact the performance of the application:
1.- Load all information in the same vuex action where the user authenticates. I have an action to validate the user and password and it creates the cookies and token sessions. I can load all information in the same action but the authentication process could be slower. With this option the load of information is executed just once.
2.- Load all information in the main/dashboard component by the fetch function consuming an vuex action (do a dispatch). It works but i am seeing that when i browse to the main/dashboard component the fetch function is always appearing. Load of information should be once after the authentication process.
3.- I also am using the nuxtserverinit to load all information when the users press F5 button or reload the web application but if i do a reload in the main/dashboard component i am seeing nuxtserverinit and fetch functions . I am duplicating resources.
I really appreciate your help.
Thanks in advance.
vue.js vuejs2 vuex nuxt.js nuxt
i am not a developer but i am deploying a web application using nuxt and i have a doubt about load all information related to the users once in the application, all the information is managed by vuex. I need to load all information after the authentication process because i am showing a dashboard to the user. I have read and found the next options but i don't know where is the best practice without impact the performance of the application:
1.- Load all information in the same vuex action where the user authenticates. I have an action to validate the user and password and it creates the cookies and token sessions. I can load all information in the same action but the authentication process could be slower. With this option the load of information is executed just once.
2.- Load all information in the main/dashboard component by the fetch function consuming an vuex action (do a dispatch). It works but i am seeing that when i browse to the main/dashboard component the fetch function is always appearing. Load of information should be once after the authentication process.
3.- I also am using the nuxtserverinit to load all information when the users press F5 button or reload the web application but if i do a reload in the main/dashboard component i am seeing nuxtserverinit and fetch functions . I am duplicating resources.
I really appreciate your help.
Thanks in advance.
vue.js vuejs2 vuex nuxt.js nuxt
vue.js vuejs2 vuex nuxt.js nuxt
asked Nov 11 at 1:43
aaaguirrep
33
33
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
1
down vote
Loading application content is not a part of authentication process, so it should be separated because of responsibility concerns.
It is a good practice to load content on the page which it is relevant to. Using fetch
repeats itself, but it is possible to check if content has been loaded inside fetch
hook and dispatch action only if required state is not present is store.
This way no additional requests are made and information is only loaded after user has been granted access to the dashboard.
Hi, thansk for your response. How would be the check by fetch hook? Are you referring to a "if" validation for instance?
– aaaguirrep
Nov 11 at 14:21
That is correct. Checking getters/state for being empty and making requests in such case. It is a simple, but efficient solution. If you are looking into something more automated, there are caching layers for request libraries, which can take care of caching responses. For example, one for axios - axios-cache-adapter.
– aBiscuit
Nov 11 at 16:38
1
Good idea, i am going to try the option and check the library for caching responses.
– aaaguirrep
Nov 12 at 2:41
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53245135%2fnuxtj-best-practice-to-load-all-information-of-users-after-the-authentication%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
Loading application content is not a part of authentication process, so it should be separated because of responsibility concerns.
It is a good practice to load content on the page which it is relevant to. Using fetch
repeats itself, but it is possible to check if content has been loaded inside fetch
hook and dispatch action only if required state is not present is store.
This way no additional requests are made and information is only loaded after user has been granted access to the dashboard.
Hi, thansk for your response. How would be the check by fetch hook? Are you referring to a "if" validation for instance?
– aaaguirrep
Nov 11 at 14:21
That is correct. Checking getters/state for being empty and making requests in such case. It is a simple, but efficient solution. If you are looking into something more automated, there are caching layers for request libraries, which can take care of caching responses. For example, one for axios - axios-cache-adapter.
– aBiscuit
Nov 11 at 16:38
1
Good idea, i am going to try the option and check the library for caching responses.
– aaaguirrep
Nov 12 at 2:41
add a comment |
up vote
1
down vote
Loading application content is not a part of authentication process, so it should be separated because of responsibility concerns.
It is a good practice to load content on the page which it is relevant to. Using fetch
repeats itself, but it is possible to check if content has been loaded inside fetch
hook and dispatch action only if required state is not present is store.
This way no additional requests are made and information is only loaded after user has been granted access to the dashboard.
Hi, thansk for your response. How would be the check by fetch hook? Are you referring to a "if" validation for instance?
– aaaguirrep
Nov 11 at 14:21
That is correct. Checking getters/state for being empty and making requests in such case. It is a simple, but efficient solution. If you are looking into something more automated, there are caching layers for request libraries, which can take care of caching responses. For example, one for axios - axios-cache-adapter.
– aBiscuit
Nov 11 at 16:38
1
Good idea, i am going to try the option and check the library for caching responses.
– aaaguirrep
Nov 12 at 2:41
add a comment |
up vote
1
down vote
up vote
1
down vote
Loading application content is not a part of authentication process, so it should be separated because of responsibility concerns.
It is a good practice to load content on the page which it is relevant to. Using fetch
repeats itself, but it is possible to check if content has been loaded inside fetch
hook and dispatch action only if required state is not present is store.
This way no additional requests are made and information is only loaded after user has been granted access to the dashboard.
Loading application content is not a part of authentication process, so it should be separated because of responsibility concerns.
It is a good practice to load content on the page which it is relevant to. Using fetch
repeats itself, but it is possible to check if content has been loaded inside fetch
hook and dispatch action only if required state is not present is store.
This way no additional requests are made and information is only loaded after user has been granted access to the dashboard.
answered Nov 11 at 2:21
aBiscuit
1,3811613
1,3811613
Hi, thansk for your response. How would be the check by fetch hook? Are you referring to a "if" validation for instance?
– aaaguirrep
Nov 11 at 14:21
That is correct. Checking getters/state for being empty and making requests in such case. It is a simple, but efficient solution. If you are looking into something more automated, there are caching layers for request libraries, which can take care of caching responses. For example, one for axios - axios-cache-adapter.
– aBiscuit
Nov 11 at 16:38
1
Good idea, i am going to try the option and check the library for caching responses.
– aaaguirrep
Nov 12 at 2:41
add a comment |
Hi, thansk for your response. How would be the check by fetch hook? Are you referring to a "if" validation for instance?
– aaaguirrep
Nov 11 at 14:21
That is correct. Checking getters/state for being empty and making requests in such case. It is a simple, but efficient solution. If you are looking into something more automated, there are caching layers for request libraries, which can take care of caching responses. For example, one for axios - axios-cache-adapter.
– aBiscuit
Nov 11 at 16:38
1
Good idea, i am going to try the option and check the library for caching responses.
– aaaguirrep
Nov 12 at 2:41
Hi, thansk for your response. How would be the check by fetch hook? Are you referring to a "if" validation for instance?
– aaaguirrep
Nov 11 at 14:21
Hi, thansk for your response. How would be the check by fetch hook? Are you referring to a "if" validation for instance?
– aaaguirrep
Nov 11 at 14:21
That is correct. Checking getters/state for being empty and making requests in such case. It is a simple, but efficient solution. If you are looking into something more automated, there are caching layers for request libraries, which can take care of caching responses. For example, one for axios - axios-cache-adapter.
– aBiscuit
Nov 11 at 16:38
That is correct. Checking getters/state for being empty and making requests in such case. It is a simple, but efficient solution. If you are looking into something more automated, there are caching layers for request libraries, which can take care of caching responses. For example, one for axios - axios-cache-adapter.
– aBiscuit
Nov 11 at 16:38
1
1
Good idea, i am going to try the option and check the library for caching responses.
– aaaguirrep
Nov 12 at 2:41
Good idea, i am going to try the option and check the library for caching responses.
– aaaguirrep
Nov 12 at 2:41
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53245135%2fnuxtj-best-practice-to-load-all-information-of-users-after-the-authentication%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown