Look up the first route pointing at the specified target (e.g. MeController.login
) and return its URL.
sails.getUrlFor(target);
Argument | Type | Details | |
---|---|---|---|
1 | target | The route target string; e.g. MeController.login |
Type:
'/login'
In a view...
<a href="<%= sails.getUrlFor('PageController.login') %>">Login</a>
<a href="<%= sails.getUrlFor('PageController.signup') %>">Signup</a>
- This function searches the Sails app's explicitly configured routes;
sails.config.routes
. Shadow routes bound by hooks (including blueprint routes) will not be matched.- If a matching target cannot be found, this function throws an
E_NOT_FOUND
error (i.e. if you catch the error and check itscode
property, it will be the stringE_NOT_FOUND
).- If more than one route matches the specified target, the first match is returned.