title: How to use the GET and POST method in the same endpoint using nodejs / express
body: <p><strong>Problem</strong></p>
  <p>Hello,</p>
  <p>I would like to know how I can create an Endpoint that first uses the POST method to login and obtain the token and then use that Token and use it in a GET method to access some data.</p>
  <p>As you will see in the code, I currently have the logic of the POST apart and the GET apart, but my intention is to be able to have an endpoint that uses both methods.</p>
  <p>The idea would be that after the POST method returns the token to me, I can use it later in the GET method.</p>
  <p>I will appreciate your help and your prompt response!</p>
  <p><strong>code</strong></p>
  <pre class="lang-js prettyprint-override"><code>app.post('/api/datas/login', async(req, res) =&gt;{
    const url = '...';
    const options = {
      email: process.env.EMAIL,
      password: process.env.PASSWORD
    }
    const call = await axios.post(url, options)
    const token = call.status === 200 ? call.data.token : null;
    res.send({
      status: call.status,
      message: 'Logged In'
    })
  });
  
  app.get('/api/datas/alldata', async(req, res) =&gt;{
    try {
      const url = '...'
      const call = await axios.get(url,{ 
        headers: {
          &quot;Authorization&quot; : `Bearer ${token}` //I need to use the token value from the POST method here!
        }
      });
      const data = call.status === 200 ? call.data : null;
      console.log(data);
      res.status(200).json(data);
  
    } catch (error) {
      res.status(500).send({ message: error });
    }
  })
  </code></pre>