When working with an express route,
page.js
router.post('/results', (req, res, next) => {
output.terms = "hello"
output.results = [{"text": "hello world"}, {"text": "hello sunshine"}]
res.render("/myview",output)
})
The code above successfully displays the text.
myview.pug
extends ../layout.pug
block content
each result in results
span=result.text
However, when attempting to use the following vue component, an error occurs stating TypeError: results is undefined
results-view.vue
<template lang="pug">
li(v-for='result in results')
span {{ result.text }}
</template>
<script>
export default {
...
}
</script>
myview.pug
extends ../layout.pug
block content
results-view
If you are wondering how to pass data from the router to the vue component, it can be a bit trickier and may require additional steps.