javascript - findOne throwing undefined even though the data is there -


i'm new meteor i've been playing around , i'm stuck problem.

i'm using react router try show theme based in url /(:userid). if there's no userid inserted url should show current user's theme , if there's no current user should show default theme.

it's working randomly. correct theme, sometime throws undefined when reading themecolor though data there. can see console.log right id, still findone can throws undefined. specially happens when change url (/xyz) , go default 1 (/).

i verified console userid actual owner of themecolor , themetextcolor.

i'm using react, react-router, autopublish. removed insecure.

getmeteordata() {      var currentviewedpageid = this.props.params.userid? this.props.params.userid:(meteor.userid()?meteor.userid():false);     console.log(currentviewedpageid); //allways right     console.log(personalization.findone({owner: currentviewedpageid}).themecolor); //sometimes undefined, not     if(currentviewedpageid)     {          return {         currentuser: meteor.user(),         themecolor: personalization.findone({owner: currentviewedpageid}).themecolor,         themetextcolor: personalization.findone({owner: currentviewedpageid}).themetextcolor         };     }     return {         currentuser: meteor.user()     }  }, 

since code working sometime. there can test data doesn't match schema. test data in collection.


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -