Node.js render alert

im having a little trouble getting an alert warning to show up on a page when the user inputs a string into a form that is less than some number of characters. The code is working except for actually displaying the error on the actual page. the main app.js has the following function to handle the input error

app.post('/register', 
  body('name').isLength({ min: 5 })
, (req, res)=> {
  const errors = validationResult(req)
  if(!errors.isEmpty()) {

      const alert = errors.array()

      app.get('/store', function(req, res){
        fs.readFile('items.json', function(error, data){
            if(error){
                res.status(500).end()
            }
            else {
                res.render('store.ejs', {
                    items: JSON.parse(data),
                    alert
                })
            }
        })
      })

      console.log('--> length error')
  }
})

The main app.js already has a (below) function to start the store page upon request also.

app.get('/store', function(req, res){ ...

in the store.ejs i have:

        <% if(typeof alert != 'undefined') { %>
            <% alert.forEach(function(error) { %>
                <div class="alert alert-warning alert-dismissible fade show" role="alert">
                    <%= error.msg %>
                    <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                    </button>
                </div>
            <% }) %>
        <% } %>