E
E
Evgeny Trofimov2017-08-23 00:12:32
Express.js
Evgeny Trofimov, 2017-08-23 00:12:32

How to configure routing correctly (Express, vue)?

There is a table made in vue (based on the table from vue-bootstrap ), which can be sorted by anyone, there is pagination and search. In data something like

filter: null,
sortBy: null,
sortDesc: false,
selectedPosition: '',
selectedType: '',
selectedRarity: '',
selectedGroup: '',

I want the parameters to be set in GET, well, that is. at
?page=2&position=event&sortBy=name&sortDesc=true&search=abs
the table was immediately rendered with parameters. Quite perfect - if so -
/page/2?position=event&sortBy=name&sortDesc=true&search=abs
.
What is the best way to do this? Where to catch parameters? Through req.query in Express ? Or via this.$route.query in vue. How do I change the options link when another option is selected in the select ? Is it possible to combine express and vue at all? Because when I do something like this:
const router = new VueRouter({
  mode: 'history',
    routes: [
        { path: '/page/:id', components:table, props: true}
    ]
});

express starts swearing at cannot GET...

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander, 2017-08-23
@boratsagdiev

You can combine. You need this module https://www.npmjs.com/package/express-history-api-... to set up a fallback from /page/:id to index.html (through which vue works) with it.
The same can be done through a web server (nginx, apache), but since you already have express, do it through it. Read more here:
https://router.vuejs.org/en/essentials/history-mod...

N
numfin, 2017-11-14
@numfin

route.query. read the docs plz

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question