LOGIN
Steven Reubenstone
50
Community Expert
Mechanical Engineer & Tinkerer of Things. Collaborizm Roundtable.
 · New YorkU.S.
Share
Report
Get Link
QUESTION
Open

noob js question

Am I do something fundamentally wrong with my string search or if statements? I can’t get dog to log anything.

app.post('/sms', async (req, res) => {
  console.log('post body', req.body);

    var signup = req.body.Body;
    var isSignup = submit.includes("signup");

    var get = req.body.Body;
    var isGet = submit.includes("get");

    var submit = req.body.Body;
    var isSubmit = submit.includes("submit");

    let dog = 0;

        if (isSignup) {
              dog = 0;
              

        } else if (isGet) {
              dog = 1;
              

        } else if (isSubmit) {
               dog = 2;
               
        }
        else
        
            dog = 3;

            
    }

);
1 like 
Like
Award Contribution
Ranjan Dailata
92
Community Expert
Solution Architect. Collaborizm Roundtable.
 · MysuruIndia
Share
Report
Get Link

The code basically checks for submit includes a text… You need to make one small change 😃

Change from - var signup = req.body.Body;
To - var submit = req.body.Body;

Like
2 likes 
Award Contribution
Steven Reubenstone
50
Community Expert
Mechanical Engineer & Tinkerer of Things. Collaborizm Roundtable.
 · New YorkU.S.
Share
Report
Get Link

wow its amazing how noob devs make these mistakes

Like
0 like 
Award Contribution
Leave a reply...
DISCOVER
CHAT
HIRE
ACTIVITY
FEED
Chat with us!
Help
Write something before you submit it!
Photo updated
Request Sent!
Updated
Copied to Clipboard