Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import Routr from "routr"
const router = new Routr({
'triangle': {path: "/", method: "get"},
'about': {path: "/about", method: "get"},
});
export default router;
import Router from "routr"
import _ from "lodash"
const paths = {
'about': "/about",
'triangle': "/triangle",
};
const router = new Router(_.mapValues(paths, path => ({path: path, method: "get"})));
export function getLocation() {
return window.location.hash.substr(1);
}
export function getRoute() {
return router.getRoute(getLocation()) || {name: '404'};
}
import Router from 'routr'
import { setTitle } from './actions/metaHeader'
import { yelpSearch, yelpBusiness } from './actions/yelp'
const routing = new Router({
search: {
path: '/',
handler: (store, route) => store.dispatch(yelpSearch(route.query))
},
business: {
path: '/business/:id',
handler: (store, route) => store.dispatch(yelpBusiness(route.params.id))
.then(action => store.dispatch(setTitle(action.payload.name)))
}
})
export default routing