1

I want to use output of my function as a string variable.

I have this function:

schemaTitle: function() {
    return Categories.findOne({_id: "Gt5prgS4RW3GW23NG"}).title;
}

now I want to use output of above return like a string variable, somewhere like this:

switch(this.schemaTitle) {
    case "HOME":
        return {
            schemaName: "StateSchema"
        };
        break; 
}

how can I do this?

1 Answer 1

4

You are not invoking the function schemaTitle, only referencing it. Just replace

switch(this.schemaTitle) {

with

switch(this.schemaTitle()) {

to invoke the function and use its return value.

Sign up to request clarification or add additional context in comments.

2 Comments

Nice catch, +1 for that
thanks. I'm sorry that because of my low reputation I can not vote up your answer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.