this.whatever is undefined
See original GitHub issueHi,
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:
- Created 5 years ago
- Comments:7 (4 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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.
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