I'm currently working on a dashboard, and need to fetch a lot of info from APIs and make the info. available. And I need them to be available as soon as a user logs-in.
I'm using nuxt-auth for authentication and login.
Currently, I fetch the data on login, but it's making login take so long. And the more APIs I call, the longer it takes to log-in, and there are still a number of APIs to be consumed.
Making the API calls on mount of the concerned components seems really redundant.
Please recommend a better way to do this, that won't slow down the login time, and also allow me to make all the necessary API calls at once.
Vuejs,Nuxt.js, javascript.
If you are using nuxt-auth you should be able to make the api call in then callback, it will not affect the login process at all because it will run after login process is successful. And you can also call your api request without using await keyword if they doesn't depend on each other, all requests will process simultaneously.
await this.$auth
.loginWith("local", {
data: {
email: this.email,
password: this.password
}
})
.then(() => {
this.$router.push("/");
// write your api requests down here
}).catch((err) => {})