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
CodePudding user response:
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
}