Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Node.js Post Data

I don’t know much about Node.js but I’m trying to modify an existing application I currently use. What I’m trying to do is when post data contain either pin number 1234 or 0000, it does the steps below. When any other pin is used. It does nothing. Below is my way of explaining it.

if(
  (req.path === '/sessions' || req.path === '/sessions/')
    && (req.method === 'POST' and pin =1234 or 0000)
){Do this step}

else if
(
  (req.path === '/sessions' || req.path === '/sessions/')
    && (req.method === 'POST')
){Do this step}

I know this should be easy. I just starting to learn. Thanks for the help

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

and should be changed to &&, or should be changed to ||. There are also some other problems, all of which are fixed below

if ((req.path === '/sessions' || req.path === '/sessions/') && (req.method === 'POST' && (pin === 1234 || pin === 0000))) {
    // do whatever
} else if ((req.path === '/sessions' || req.path === '/sessions/') && req.method === 'POST'){
    // do whatever
}
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading