title: how to return a user id from an express backend server
body: <p>Working on the login for a stock application. When the user typs in their email and password the users ID which is currently hardcoded in my server will be returned to the console. I will use that ID to save it to local storage to keep the session alive and allow access to my protected routes. I am unable to return the user ID with my current logic.</p>
  <p>Backend</p>
  <pre><code>let users = [
      {
          id: 1,
          userName: 'user1',
          email: 'abc@email.com',
          password: 'abc'
      },
      {
          id: 2,
          userName: 'user2',
          email: '123@email.com',
          password: '123'
      }
  ]
  
      app.post('/api/auth', (req, res) =&gt; {
          let userResult = users.find(user =&gt; user.email === req.body.email);
          if (userResult) {
              if (userResult.password === req.body.password) {
                  res.status(200).send({
                      message: true,
                      user: users.id
                  })
              } else {
                  res.status(200).send({
                      message: false
                  })
              }
          } else {
              res.status(200).send({
                  message: false
              })
          }
      });
  
  </code></pre>
  <p>Front end</p>
  <pre><code>handleSubmit = e =&gt; {
          e.preventDefault()
          const request = {
              email: this.state.userEmail,
              password: this.state.userPassword
          }
          if (this.state.userEmail === '' || this.state.userPassword === '') {
              alert('Enter Username and Password')
          } else {
              this.setState({userEmail: '', userPassword: ''})
          }
          axios.post(`http://localhost:3000/api/auth`, request)
              .then(res =&gt; {
                  if (res.data.message) {
                      console.log(res.data.user)
                      //add user ID to local storage.
                      //this.props.history.push('/dashboard') Re-directs to dashboard page!!!
                      this.setState({isAuth: true})
                  } else {
                      alert('Invalid username or password')
                      this.setState({isAuth: false, userEmail: '', userPassword: ''})
                  }
              console.log(res.data.message)
              })
              .catch(err =&gt; {
                  console.log(err)
              })
      }
  
  </code></pre>