Error in callback for watcher “get_settings”: “TypeError: Cannot read property ‘general’ of...
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}
Please help me out, how to handle this error i cant seem to handle this out as i am new to vue.
what im doing is getting data from server in store vuex with action. Now in component im accessing that data with getter in computed property and trying to watch that property but on component mount i get that error in console but functionality works fine.
data:function()
{
return{
settings_flags:{
general:0,
privacy:0,
layouts:0,
message:0
},
}
}
1: mounting
mounted(){
let self =this;
self.userid = this.getUserId();
this.$store.dispatch('getGallerySettings',self.req);
self.initial_settings();
},
2:computed
computed: {
get_settings(){
return this.$store.getters.getGallerySettings;
},
},
3: watch
watch:{
'get_settings':{
deep: true,
handler() {
let self =this;
if(this.$_.isMatch(self.get_settings.gallery_settings.general,self.initialSettings.gallery_settings.general) == false){
self.settings_flags.general = 1;
}else{
self.settings_flags.general = 0;
}
},
},
vue.js vuejs2 vuex
add a comment |
Please help me out, how to handle this error i cant seem to handle this out as i am new to vue.
what im doing is getting data from server in store vuex with action. Now in component im accessing that data with getter in computed property and trying to watch that property but on component mount i get that error in console but functionality works fine.
data:function()
{
return{
settings_flags:{
general:0,
privacy:0,
layouts:0,
message:0
},
}
}
1: mounting
mounted(){
let self =this;
self.userid = this.getUserId();
this.$store.dispatch('getGallerySettings',self.req);
self.initial_settings();
},
2:computed
computed: {
get_settings(){
return this.$store.getters.getGallerySettings;
},
},
3: watch
watch:{
'get_settings':{
deep: true,
handler() {
let self =this;
if(this.$_.isMatch(self.get_settings.gallery_settings.general,self.initialSettings.gallery_settings.general) == false){
self.settings_flags.general = 1;
}else{
self.settings_flags.general = 0;
}
},
},
vue.js vuejs2 vuex
Please share with us what your specific error is. Generally this sort of error happens when data is not yet present when the component is created, but appears later. When the data appears, everything works. The error will disappear if you check for the missing data before using it.
– Katinka Hesselink
Nov 16 '18 at 15:47
yes i know initially data does not appears which is causing error but i am not figuring out how to handle it. i am using watch on computed property which is getting data from server as it take some time to load thats why watch gives me error of undefined and if i check length of property like if length is greater than 0 than do watch due to it this never watches data
– Bini
Nov 16 '18 at 16:06
I really need the precise error text to help you further.
– Katinka Hesselink
Nov 16 '18 at 16:14
[Vue warn]: Error in callback for watcher "get_settings": "TypeError: Cannot read property 'general' of undefined" found in ---> <GallerySettings> at resources/assets/js/components/gallery/gallerySetting/gallery_settings.vue <Root> TypeError: Cannot read property 'general' of undefined at VueComponent.handler (app.js:62446) at Watcher.run (app.js:33534) at flushSchedulerQueue (app.js:33282) at Array.<anonymous> (app.js:32138) at flushCallbacks (app.js:32059)
– Bini
Nov 16 '18 at 16:29
add a comment |
Please help me out, how to handle this error i cant seem to handle this out as i am new to vue.
what im doing is getting data from server in store vuex with action. Now in component im accessing that data with getter in computed property and trying to watch that property but on component mount i get that error in console but functionality works fine.
data:function()
{
return{
settings_flags:{
general:0,
privacy:0,
layouts:0,
message:0
},
}
}
1: mounting
mounted(){
let self =this;
self.userid = this.getUserId();
this.$store.dispatch('getGallerySettings',self.req);
self.initial_settings();
},
2:computed
computed: {
get_settings(){
return this.$store.getters.getGallerySettings;
},
},
3: watch
watch:{
'get_settings':{
deep: true,
handler() {
let self =this;
if(this.$_.isMatch(self.get_settings.gallery_settings.general,self.initialSettings.gallery_settings.general) == false){
self.settings_flags.general = 1;
}else{
self.settings_flags.general = 0;
}
},
},
vue.js vuejs2 vuex
Please help me out, how to handle this error i cant seem to handle this out as i am new to vue.
what im doing is getting data from server in store vuex with action. Now in component im accessing that data with getter in computed property and trying to watch that property but on component mount i get that error in console but functionality works fine.
data:function()
{
return{
settings_flags:{
general:0,
privacy:0,
layouts:0,
message:0
},
}
}
1: mounting
mounted(){
let self =this;
self.userid = this.getUserId();
this.$store.dispatch('getGallerySettings',self.req);
self.initial_settings();
},
2:computed
computed: {
get_settings(){
return this.$store.getters.getGallerySettings;
},
},
3: watch
watch:{
'get_settings':{
deep: true,
handler() {
let self =this;
if(this.$_.isMatch(self.get_settings.gallery_settings.general,self.initialSettings.gallery_settings.general) == false){
self.settings_flags.general = 1;
}else{
self.settings_flags.general = 0;
}
},
},
vue.js vuejs2 vuex
vue.js vuejs2 vuex
asked Nov 16 '18 at 15:43
BiniBini
11
11
Please share with us what your specific error is. Generally this sort of error happens when data is not yet present when the component is created, but appears later. When the data appears, everything works. The error will disappear if you check for the missing data before using it.
– Katinka Hesselink
Nov 16 '18 at 15:47
yes i know initially data does not appears which is causing error but i am not figuring out how to handle it. i am using watch on computed property which is getting data from server as it take some time to load thats why watch gives me error of undefined and if i check length of property like if length is greater than 0 than do watch due to it this never watches data
– Bini
Nov 16 '18 at 16:06
I really need the precise error text to help you further.
– Katinka Hesselink
Nov 16 '18 at 16:14
[Vue warn]: Error in callback for watcher "get_settings": "TypeError: Cannot read property 'general' of undefined" found in ---> <GallerySettings> at resources/assets/js/components/gallery/gallerySetting/gallery_settings.vue <Root> TypeError: Cannot read property 'general' of undefined at VueComponent.handler (app.js:62446) at Watcher.run (app.js:33534) at flushSchedulerQueue (app.js:33282) at Array.<anonymous> (app.js:32138) at flushCallbacks (app.js:32059)
– Bini
Nov 16 '18 at 16:29
add a comment |
Please share with us what your specific error is. Generally this sort of error happens when data is not yet present when the component is created, but appears later. When the data appears, everything works. The error will disappear if you check for the missing data before using it.
– Katinka Hesselink
Nov 16 '18 at 15:47
yes i know initially data does not appears which is causing error but i am not figuring out how to handle it. i am using watch on computed property which is getting data from server as it take some time to load thats why watch gives me error of undefined and if i check length of property like if length is greater than 0 than do watch due to it this never watches data
– Bini
Nov 16 '18 at 16:06
I really need the precise error text to help you further.
– Katinka Hesselink
Nov 16 '18 at 16:14
[Vue warn]: Error in callback for watcher "get_settings": "TypeError: Cannot read property 'general' of undefined" found in ---> <GallerySettings> at resources/assets/js/components/gallery/gallerySetting/gallery_settings.vue <Root> TypeError: Cannot read property 'general' of undefined at VueComponent.handler (app.js:62446) at Watcher.run (app.js:33534) at flushSchedulerQueue (app.js:33282) at Array.<anonymous> (app.js:32138) at flushCallbacks (app.js:32059)
– Bini
Nov 16 '18 at 16:29
Please share with us what your specific error is. Generally this sort of error happens when data is not yet present when the component is created, but appears later. When the data appears, everything works. The error will disappear if you check for the missing data before using it.
– Katinka Hesselink
Nov 16 '18 at 15:47
Please share with us what your specific error is. Generally this sort of error happens when data is not yet present when the component is created, but appears later. When the data appears, everything works. The error will disappear if you check for the missing data before using it.
– Katinka Hesselink
Nov 16 '18 at 15:47
yes i know initially data does not appears which is causing error but i am not figuring out how to handle it. i am using watch on computed property which is getting data from server as it take some time to load thats why watch gives me error of undefined and if i check length of property like if length is greater than 0 than do watch due to it this never watches data
– Bini
Nov 16 '18 at 16:06
yes i know initially data does not appears which is causing error but i am not figuring out how to handle it. i am using watch on computed property which is getting data from server as it take some time to load thats why watch gives me error of undefined and if i check length of property like if length is greater than 0 than do watch due to it this never watches data
– Bini
Nov 16 '18 at 16:06
I really need the precise error text to help you further.
– Katinka Hesselink
Nov 16 '18 at 16:14
I really need the precise error text to help you further.
– Katinka Hesselink
Nov 16 '18 at 16:14
[Vue warn]: Error in callback for watcher "get_settings": "TypeError: Cannot read property 'general' of undefined" found in ---> <GallerySettings> at resources/assets/js/components/gallery/gallerySetting/gallery_settings.vue <Root> TypeError: Cannot read property 'general' of undefined at VueComponent.handler (app.js:62446) at Watcher.run (app.js:33534) at flushSchedulerQueue (app.js:33282) at Array.<anonymous> (app.js:32138) at flushCallbacks (app.js:32059)
– Bini
Nov 16 '18 at 16:29
[Vue warn]: Error in callback for watcher "get_settings": "TypeError: Cannot read property 'general' of undefined" found in ---> <GallerySettings> at resources/assets/js/components/gallery/gallerySetting/gallery_settings.vue <Root> TypeError: Cannot read property 'general' of undefined at VueComponent.handler (app.js:62446) at Watcher.run (app.js:33534) at flushSchedulerQueue (app.js:33282) at Array.<anonymous> (app.js:32138) at flushCallbacks (app.js:32059)
– Bini
Nov 16 '18 at 16:29
add a comment |
1 Answer
1
active
oldest
votes
It seems to me that your watcher is looking for a property 'general' that is a child of gallery_settings.
get_settings.gallery_settings.general
In the meantime in data you have a property general that is a child of 'settings_flags'. Those two don't line up. So make sure that either your watcher is looking for something that exists when the component starts up, or tell your watcher to only start watching ' get_settings.gallery_settings.general' when 'get_settings.gallery_settings' actually exists.
if (get_settings.gallery_settings) { do something } #pseudocode
I'm not sure that's your problem, but it might be.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53341112%2ferror-in-callback-for-watcher-get-settings-typeerror-cannot-read-property%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
It seems to me that your watcher is looking for a property 'general' that is a child of gallery_settings.
get_settings.gallery_settings.general
In the meantime in data you have a property general that is a child of 'settings_flags'. Those two don't line up. So make sure that either your watcher is looking for something that exists when the component starts up, or tell your watcher to only start watching ' get_settings.gallery_settings.general' when 'get_settings.gallery_settings' actually exists.
if (get_settings.gallery_settings) { do something } #pseudocode
I'm not sure that's your problem, but it might be.
add a comment |
It seems to me that your watcher is looking for a property 'general' that is a child of gallery_settings.
get_settings.gallery_settings.general
In the meantime in data you have a property general that is a child of 'settings_flags'. Those two don't line up. So make sure that either your watcher is looking for something that exists when the component starts up, or tell your watcher to only start watching ' get_settings.gallery_settings.general' when 'get_settings.gallery_settings' actually exists.
if (get_settings.gallery_settings) { do something } #pseudocode
I'm not sure that's your problem, but it might be.
add a comment |
It seems to me that your watcher is looking for a property 'general' that is a child of gallery_settings.
get_settings.gallery_settings.general
In the meantime in data you have a property general that is a child of 'settings_flags'. Those two don't line up. So make sure that either your watcher is looking for something that exists when the component starts up, or tell your watcher to only start watching ' get_settings.gallery_settings.general' when 'get_settings.gallery_settings' actually exists.
if (get_settings.gallery_settings) { do something } #pseudocode
I'm not sure that's your problem, but it might be.
It seems to me that your watcher is looking for a property 'general' that is a child of gallery_settings.
get_settings.gallery_settings.general
In the meantime in data you have a property general that is a child of 'settings_flags'. Those two don't line up. So make sure that either your watcher is looking for something that exists when the component starts up, or tell your watcher to only start watching ' get_settings.gallery_settings.general' when 'get_settings.gallery_settings' actually exists.
if (get_settings.gallery_settings) { do something } #pseudocode
I'm not sure that's your problem, but it might be.
answered Nov 19 '18 at 8:12
Katinka HesselinkKatinka Hesselink
676616
676616
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53341112%2ferror-in-callback-for-watcher-get-settings-typeerror-cannot-read-property%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Please share with us what your specific error is. Generally this sort of error happens when data is not yet present when the component is created, but appears later. When the data appears, everything works. The error will disappear if you check for the missing data before using it.
– Katinka Hesselink
Nov 16 '18 at 15:47
yes i know initially data does not appears which is causing error but i am not figuring out how to handle it. i am using watch on computed property which is getting data from server as it take some time to load thats why watch gives me error of undefined and if i check length of property like if length is greater than 0 than do watch due to it this never watches data
– Bini
Nov 16 '18 at 16:06
I really need the precise error text to help you further.
– Katinka Hesselink
Nov 16 '18 at 16:14
[Vue warn]: Error in callback for watcher "get_settings": "TypeError: Cannot read property 'general' of undefined" found in ---> <GallerySettings> at resources/assets/js/components/gallery/gallerySetting/gallery_settings.vue <Root> TypeError: Cannot read property 'general' of undefined at VueComponent.handler (app.js:62446) at Watcher.run (app.js:33534) at flushSchedulerQueue (app.js:33282) at Array.<anonymous> (app.js:32138) at flushCallbacks (app.js:32059)
– Bini
Nov 16 '18 at 16:29