How to use forwardTo with parameters?
See original GitHub issueBasically I want to automatically forward this route:
/channel/:channel_id/
to this one:
/:client_id/channel/:channel_id/
But, since the first route does not specify any client_id
, I want to use a default value of “foo”.
This is what I have but obviously does not work:
const router = createRouter(
// routes
[
{
name : 'channel',
path : '/:client_id/channel/:channel_id/'
},
{
name : 'channel_old_api',
path : '/channel/:channel_id/',
forwardTo : 'channel'
}
],
// options
{
defaultRoute : 'channel',
defaultParams :
{
client_id : 'foo',
channel_id : 'lalala'
},
trailingSlash : true,
strictQueryParams : false
});
If I open the browser in https://localhost/#/channel/alpha/
it fails with:
Uncaught Error: Cannot build path: '/:client_id/meet/:channel_id/' requires missing parameters { client_id }
Is there any way to use forwardTo
with extra default parameters? Something like:
{
name : 'channel_old_api',
path : '/channel/:channel_id/',
forwardTo : 'channel',
forwardParams : { client_id: 'foo' }
}
Thanks a lot.
Issue Analytics
- State:
- Created 6 years ago
- Comments:8 (4 by maintainers)
Top Results From Across the Web
Problem with forwardTo with parameters - Vaadin
But I have a strange behaviour when using forwardTo compared to rerouteTo event.forwardTo(MainView.class); becomes http://127.0.0.1/main (parameters are ...
Read more >missing URL parameters when using event.forwardTo("xxx")
forwardTo forwards to another view and is changing the URL. But the URL parameters are lost and not transfered. When using event.
Read more >vaadin strip query parameters when calling forwardTo
I've tried using UI.navigateTo but that doesn't appear to work in a beforeEnter handler. So how do I remove the query parameters?
Read more >The Complete Guide to URL parameters with React Router
In this post you'll learn how to use URL parameters with React Router. ... When's the last time you actually looked forward to...
Read more >Forward to different URL and pass parameters - CodeRanch
I need to pass some parameters with "POST" to a different site( The requestDispatcher only takes context relative paths and the ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Will do! The PR is ready: #244, will probably release tomorrow or friday
Yeah sure, the docs will be updated before release