title: performing select query inside checkout function
body: <p>I have this function with the following code below:</p>
  <pre><code> app.post('/create-checkout-session', async (req, res) =&gt; {
      console.log(req.session.username)
      let price = &quot;&quot;
      var getUserPaymentData = &quot;select * from INVOICES where USER = '&quot; + req.session.username + &quot;'&quot;
      ibmdb.open(ibmdbconnMaster, function(err, conn) {
          if (err) return console.log(err);
          conn.query(getUserPaymentData, function(err, rows) {
              if (err) {
                  console.log(err);
              }
  
              
              for (var i = 0; i &lt; rows.length; i++) {
                  console.log(&quot;rows of lengths are: &quot; + rows.length)
                  var price1 = rows[i][&quot;AMOUNTOWED&quot;]
                  console.log(rows[i][&quot;USER&quot;])
                  price = parseInt(price1)
                  console.log(price1)
              }
              conn.close(function() {
                  console.log(&quot;closed the function /create-checkout-session&quot;);
              });
              });
          })
  
         console.log(price)
  
    const session = await stripe.checkout.sessions.create({
      payment_method_types: ['card'],
      line_items: [
        {
          price_data: {
            currency: 'usd',
            product_data: {
              name: 'Marcos Swim School Payment',
            },
            unit_amount: price,
          },
          quantity: 1,
        },
      ],
      mode: 'payment',
      success_url: `https://xxx.ca/`,
      cancel_url: `https://xxx.ca/cancel`,
    });
  
    res.json({ id: session.id });
   
  });
  </code></pre>
  <p>I'm basically checking how much the user owes to me, and then redirecting to checkout. However, it is totally skipping over the query and not logging anything, and then throwing the error that no price is defined. This is because I am trying to set the price after I query my table. How do I fix this?</p>