nuxt The value of this.$store has not been defined

I encountered an issue while implementing Vuex store in my Nuxt project. Despite following a helpful guide to kickstart the process, I am stuck with seeing a this.$store is undefined error.

The content of my store/index.js file:

export const state = () => ({
    userdata: {}
})

export const mutations = {
    setUserdata(state, value){
        state.userdata = value
    }
}

export const getters = {
    GetUserdata(state){ return state.userdata}
}`

In the script section of pages/login.vue:

import Vue from 'vue'
export default Vue.extend({
    name: 'LoginSuccessPage',
    async created() {
        var token = this.$route.query.token
        var data = await fetch("http://localhost:3500/profile/"+token)
        var jsondata = await data.json()
        this.$store.dispatch("userdata",jsondata)
     }
})`

Answer №1

The problem was solved by deleting the vuex entry from the package.json.

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

Updating values in an Object by assigning them with results from an array

I've been grappling with a data structure issue in nodejs and I could really use some assistance. Here's the scenario: I have an object: let obj = { commenter: '', comment: '', numberOflikes: 0, } Along with a containe ...

What is the best way to conduct a conditional check across all subsequent visible rows of a table?

When a user clicks inside the text input field and presses either the down or up arrow keys, my JavaScript function is triggered. The purpose of this functionality is to search table values and allow the user to select one by pressing the arrow keys. Every ...

The input I have is an array that has been flattened, and I am looking to transform it into a tree structure

Additionally, the node with a null value for the parent_uid is considered as the highest-level node. Input -: [ {uid: "d86161ab-1838-4cd3-afc2-20a32c08e88f", parent_uid: null}, {uid: "c64eb64e-1291-4833-b646-947f1a64a1cf", parent_uid: ...

Escape sequences do not seem to be functioning properly when using innerHTML

I am facing an issue where a string containing HTML escape characters (such as < and >) needs to be rendered inside a div using innerHTML. The intention is for the escaped characters to appear as text rather than as actual HTML, but they still render ...

execute a series of asynchronous functions one after another

async function cancelUserSubscriptionHandler() { const unsubscribe = await fetch("/api/stripe-sessions/cancel-subscription", { method: "PATCH", body: JSON.stringify(), headers: { "Content-Type": "appli ...

JavaScript group by multiple properties in an array to easily organize and sort data

I have an array of objects that I need to group by using two fields with the function groupBy(). While I can successfully group by a single field, I am having trouble achieving this with two fields. The desired output format is as follows: { data: [ ...

Setting up Vue CLI 3 to utilize webpack root folder aliases

I'm attempting to connect a static image from the assets folder to a Vue component, but I keep encountering the "Module not found: Error: Can't resolve" error message. Interestingly, when I link the image from the root component, it resolves wit ...

What is the reason behind capitalizing all words within <p> elements?

Why are all the words in my sentences capitalized randomly? Below you can see snippets of my HTML and CSS code. Any help would be greatly appreciated. Thank you in advance! HTML <!DOCTYPE html> <html lang="en"> <head> & ...

Scraping the Web for Repetitive Array Information

Struggling to eliminate duplicate articles from my web scraper results using the following code: app.get("/scrape", function (req, res) { request("https://www.nytimes.com/", function (error, response, html) { // Parsing the HTML using cheerio ...

What is the best way to transfer form data in Vue to a variable in JSON format using Axios?

I am currently using the following method: let newFormData = { productName: this.productName, productModel: this.productModel, prodDescription: this.prodDescription, prodPrice: this.prodPrice, promoPrice: this ...

DZI Openseadragon in combination with three.js creates a stunning spherical image

I successfully transformed the flat image into a spherical image using the provided source code (three js). <!DOCTYPE html> <html lang="en"> <head> <title>Spherical image conversion</title> <style> body ...

There seems to be an issue with declaring Gulp Open

Here is the code snippet for my `open.js` task: import gulp from 'gulp'; import gulpOpen from 'gulp-open'; gulp.task('open', () => { // doesn't work with `function()` either. const options = { uri: 'local ...

creating grunt shortcuts with specified option values

Is it possible to create custom aliases in Grunt, similar to npm or bash? According to the Grunt documentation, you can define a sequence of tasks (even if it's just one). Instead of calling it "aliasing", I believe it should be referred to as "chaini ...

Remove the most recently played sound from an array of sound using Vue.js

I've been trying to figure out how to randomize the sounds that play when a button is clicked, but I also want to avoid repeating the last played sound. It just doesn't sound right if the same sound plays repeatedly in quick succession. I'm ...

Ways to send a notification every time there is a modification in the back-end data?

We are dealing with a simple JSON structure like the following: { name: "Johnson" } My strategy involves utilizing AJAX to display the name as shown below: $.ajax({ url: /info.json, success: function(data) { $('<span><b ...

Personalizing buttons on a carousel in React-bootstrap

I am facing an issue with my carousel and buttons placement. The buttons need to be outside of the carousel, but I'm unsure how to connect them effectively. React-Bootstrap's activeIndex option was suggested, but since my carousel is not cyclic l ...

The Jquery hide function seems to be unresponsive when trying to close the span in my Dialog

$('.ui-dialog-titlebar-close ui-corner-all').hide(); I'm having trouble hiding the close 'X' span in my jQuery dialog. When I resize the dialog, it appears, but it's not showing correctly initially due to CSS issues. Could s ...

Difficulty encountered when loading a local image within a React JS application

I'm facing a challenge trying to showcase an image using div in react js. Even though the path is correct as I can display it with an img tag. The issue arises because I am unable to utilize the import method due to the fact that the filename will be ...

Include a checkbox within a cell of a table while utilizing ngFor to iterate through a two-dimensional array

I am working with a two-dimensional array. var arr = [ { ID: 1, Name: "foo", Email: "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="f5939a9ab5939a9adb969a98">[email protected]</a>", isChecked: "true" ...

Retrieving registered components dynamically in Vue.js

Check out my scenario on jsBin In my setup, I have a selector <component :is="selectedComponent"></component>, along with a <select v-model="currentComponent">...</select> that allows me to choose which one is displayed. Currently ...