-
Notifications
You must be signed in to change notification settings - Fork 410
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't pass params with redirect #1610
Comments
why not use Router.go? I'm not sure this.redirect still exists... Edit : |
Weird, on my Blaze onCreated/onRendered function I could not get it at all (with How did you retrieve the params? The same way as me? |
Yes I retrieve the settings the same way as you. |
... Iron router will probably no longer be updated, if you start you should use FlowRouter-extra ... |
Yes my redirect is working but no query params in it... unless I manually add them to the url to redirect to. It's not a start of a project, so can't switch to another router without a lot of work. Thanks for your time to help me. |
can you share more code of your route? |
const route = (path: string, templateName: string, options?: routeOptionsType) => {
Router.route(path, function (this: RouteController) {
if (templateName === 'Home') {
if (!Meteor.loggingIn() && !Meteor.user()) {
// this.redirect(`/login`, null, {query: Router.current().params.query}); // Did not work...
this.redirect(`/login?${(new URLSearchParams(Router.current().params.query)).toString()}`); // This is working
return;
}
}
this.render(templateName);
}, { layoutTemplate: '', template: templateName, name: options?.routerTemplateName || templateName });
};
route('/dashboard', 'Home');
route('/login', 'Login');
import { Router } from 'meteor/iron:router';
import { Meteor } from 'meteor/meteor';
import { Template } from 'meteor/templating';
import './login.hbs.html';
Template.Login.onCreated(() => {
console.log('Login', Router.current().params.query);
}); |
and this ? |
This is not working either. |
Okay we well work on it |
Inside a router function, I tried to redirect to a login page but I which to keep the params.
I thought that I can do that:
But it seems not working. I also tried,
hash
,params
,query
,randomThing
, etc..Is there a way to do so? Or should I compute back all params inside the
path
to make it work?The text was updated successfully, but these errors were encountered: