question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

this.whatever is undefined

See original GitHub issue

Hi,

I have a module with the following code:

import axios, { AxiosInstance } from "axios";
import { Module, VuexModule, Action, MutationAction, Mutation } from 'vuex-module-decorators'

@Module({ name: 'login', namespaced: true })
export default class LoginModule extends VuexModule {
    loginResult: any;
    backends: Array<string> = [
        'https://192.1686.178.6:8000/',
        'https://localhost:8000/',
        'https://192.168.1.105:8000/',
        'https://192.1686.1.12:8000/'
    ]

    @Action
    async backendLogin() {
        let api: AxiosInstance = axios.create({
            baseURL: this.backends[0]
        });
        let response;

        try {
            response = await api.post("/app/register/", {});
        } catch (ex) {
            console.log(`Error on login: ${ex}`);
        }
        return response;
    }
}

When I try to run this code I get this.backends is undefined, in fact all classproperties are undefined there. Am I missing something?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

4reactions
championswimmercommented, Sep 10, 2018

You’re not supposed to use state in actions directly, ideally do via a getter. But yes since it is a possible operation, I will add support for that.

1reaction
championswimmercommented, Sep 17, 2018

ok closing, anyone else who lands on this issue - it’ll be in production when 0.8.0 lands into @latest for now you can use @beta to get this

Read more comments on GitHub >

github_iconTop Results From Across the Web

Window.whatever is undefined - Stack Overflow
I have some code that is running correctly but occasionally Muscula reports an error that whatever is undefined . Why is it reporting...
Read more >
Why am I getting an undefined value or when I try ... - Treehouse
This is the only issue I'm having: With the Codepen, I see that whatever I type in is appearing in the console. But...
Read more >
On selectionChanged function, 'this' is undefined ?!? - GoJS
I'm using angular 2, and I need to update 'selectedData' property of the component when a node in selected.
Read more >
Why can't TeX show us the actual "undefined control ...
The undefined control sequence is the last control sequence in the first line of code reported by the error. This is in fact...
Read more >
The 10 Most Common JavaScript Issues Developers Face
If you guess that the console.log() call would either output undefined or ... And just to be sure everything looks copacetic, let's print...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found