Pass the request to server sammyjs

44 Views Asked by At

New to sammyjs. We broadly have two modules, one is Server side rendered and another is a de-coupled client app. We have implemented ko and sammy and its working good. But for some requests, I need to pass it on to the server. Is that possible with sammy?

Sammy(function () {
  this.get( ".*", function () {
    var view = window.location.pathname;
    if( view == "/" )
        appViewModel.currentView( "home-page" );
    else if( view == "/product" )
        appViewModel.currentView( "product-page" );
    else if( view == "/admin" )
        return false; // SSR Page
  });
}).run();
1

There are 1 best solutions below

0
Raghu Raman On

The answer turned out to be very simple, just don't capture the request in the first place.

this.get( "^(?!\/admin$).*$", function() {
   // Do something
});