The information from Nuxt 3 is failing to show up in the form

Technologies - Pinia, Nuxt 3

I need to update the information of a logged-in user on my platform.

When navigating using NuxtLink, the data is retrieved from the store and displayed in the form. However, if I manually refresh the page with F5, the data does not appear in the form, even though it's present in the form variable when inspected through developer tools.

<template>
  <Form
    v-slot="{ errors }"
    :validation-schema="schema"
    class="flex flex-col"
    @submit="onSubmit">
    <div class="flex flex-col mb-3">
      <label class="text-sm font-medium mb-2">Email</label>
      <UIFormFieldEmail
        v-model="form.email"
        :error="errors.email" />
    </div>
    <div class="flex flex-col mb-5">
      <label class="text-sm font-medium mb-2">First Name</label>
      <UIFormField
        v-model="form.firstName"
        :error="errors.firstName"
        name="firstName" />
    </div>
    <div class="flex flex-col mb-5">
      <label class="text-sm font-medium mb-2">Last Name</label>
      <UIFormField
        v-model="form.lastName"
        :error="errors.lastName"
        name="lastName"/>
    </div>
  </Form>
</template>

<script lang="ts" setup>
  import {
    Form,
    useForm,
    Field,
    defineRule
  } from 'vee-validate';
  import {
    useAuthStore
  } from '~/store/auth';
  import {
    storeToRefs
  } from 'pinia';


  const authStore = useAuthStore();
  const {
    user
  } = storeToRefs(authStore);

  const form = reactive({ ...user.value
  });
</script>

Answer №1

After hitting F5, your user store becomes emptied. To prevent this, you can either refetch the data and store it on that page again or use a plugin like persistedstate to persist your store data.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Exploring the use of jQuery autocomplete to retrieve data attributes

Looking to retrieve additional data-attributes from the Mapbox API. The autocomplete plugin I implemented can be found here. (Utilizing Python/Django for backend) My goal is to send extra information such as country code, city, and country to my databas ...

The functionality of $(window).load() varies between Internet Explorer and Firefox

While experimenting with $(window).load() function, I encountered a problem. The function is supposed to wait for the window to fully load before executing any code written inside it. This works correctly in IE, but not in Firefox. In Firefox, it behaves m ...

Using transition-group without the need to enclose it in a span tag

My goal is to add a transition effect to a Vuetify v-data-table, specifically when deleting a tbody element so that it fades out instead of abruptly disappearing from the screen. When I use a transition-group wrapping the tbody, the fade-out effect works a ...

Error in Three.js + OrbitControls: Undefined property 'addEventListener' is not readable

Currently, I am facing an issue while using OrbitControls in THREE.js. Whenever I remove the line let cameraControl = new OrbitControls(camera), there are no errors. However, when this line is included, I encounter a "Uncaught TypeError: Cannot read proper ...

Ensure that a div with fluid width remains consistently centered within another div

I have a bunch of boxes filled with content. The number of boxes in each row varies depending on the width of the browser window. Is there a way to ensure that all the boxes are always horizontally centered on the page? For guidance, you can check out th ...

The issue with <asp:button> not functioning properly has been detected specifically in Internet

I am facing an issue with my asp button in my application. It works perfectly fine in Mozilla, Chrome, and IE 8 but it fails to work in IE 9. I have tried various solutions but none of them seem to solve the problem. If anyone knows how to fix this, pleas ...

How are the script name and script file connected in WordPress enqueuing?

When adding a jQuery script to the function.php file using the enqueue method, how does the script name relate to the actual file that contains the jQuery code? Is the script name arbitrary, or is it derived from either the file name or the actual script w ...

Issue with onClick function causing failure to generate options in select menu

function getOption(){ var select = document.getElementById("dynamic-select"); if(select.options.length > 0) { var option = select.options[select.selectedIndex]; alert("Text: " + option.text + "\nValue: " + option.value); ...

Is there a way to access an SD card by clicking on an HTML link using JavaScript?

UPDATE: I am seeking a way to embed an HTML file with JavaScript or jQuery that can directly access the contents of the SD card while being opened in a browser. Currently, I have posted code for accessing it through an activity, but I want to be able to d ...

jQuery mobile page transition issue causing white screen error

Currently, I am in the process of using HTML, CSS, and JS to build my PhoneGap project on Eclipse. I have included jQuery and jQuery Mobile libraries in order to utilize the mobile.changepage function within my JS file. However, I am encountering an issue ...

Ajax code is not reacting

Hey there, I'm facing some issues trying to get this AJAX code up and running with JavaScript. The function is named studentReqHandler and it involves a button that triggers an onclick event. Everything in this code snippet is wrapped within echo stat ...

Vue fails to retrieve the accurate value of the option, instead displaying the text

Just started using Vue.js through CDN. Currently working with a select element: <select @change="setValue($event.target.value)"> <option>Pick</option> <option val="1">First Choice</option> <opt ...

Creating a continuous loop in JQuery when clicking on a table row

I seem to be encountering an issue with what appears to be an infinite loop. My problem arises while trying to create a table dynamically using Ajax. Each row of the table contains a button alongside a thumbnail image and some text. I wish for the button ...

What are some methods for substituting standard JavaScript built-in objects?

My client has developed their own app using Chromium, with a navigator.appVersion of AppleWebkit/534+ https://i.sstatic.net/zEZy6.jpg To my surprise, they have replaced the standard JavaScript built-in objects with their own version. For instance, take a ...

Integrating Dialogflow with a Heroku JavaScript application

After extensive research, I delved into the realm of integrating DialogFlow requests with a webhook hosted on platforms like Heroku. With both Heroku and nodeJS impeccably installed on my system, I diligently followed the heroku tutorial to kickstart the p ...

Setting up Firebase in an Angular 6 project without using AngularFire

While working on a project, I initially set up Firebase using AngularFire but found that I didn't need to use many of its functions. Instead, I imported firebase/app in each service and directly used specific functions like firebase.auth() and firebas ...

What are the best methods for conducting a load test on a JavaScript/AngularJS application?

I'm working on a JavaScript/AngularJS application that communicates with a server using websockets. Is there an efficient method to conduct a load test? I want to simulate what will occur if the app receives 100 calls simultaneously (resulting in 100 ...

Using C# to simulate a mousewheel event on an IWebElement in Selenium

Description: An intricate arrangement of HTML rectangles displayed on the screen, each with a unique HTML id attribute making them selectable by Selenium IWebDriver and C# code without any overlaps. Objective: My goal is to use Selenium and C# to programm ...

Increment button value by one using JavaScript or jQuery

I am trying to create a button that increments its value with each click, which I will then need to submit to my database. Currently, my implementation causes the incremented values to display properly, but the button text "GOAL" disappears when clicked. ...

What could be causing Nuxt-link to trigger a page refresh when paired with Bootstrap-vue?

Currently utilizing nuxt and bootstrap to construct a custom hover dropdown menu for navigation. Encountering an issue where my navigation submenu NuxtLinks are triggering a full page refresh instead of smoothly transitioning the app content within my Nuxt ...