Comments (1)
app.js
import HomeScreen from './screens/HomeScreen.js'
import ProductScreen from './screens/ProductScreen.js'
import { parseRequestUrl } from './utils.js';
import Error404Screen from './screens/Error404Screen.js'
const routes = {
'/': HomeScreen,
'/product/:id': ProductScreen,
};
const router = () => {
const request = parseRequestUrl();
const parseUrl = (request.resource ?
/${request.resource}
:/
)+ (request.id ? '/:id': '' )+
(request.verb ? /${request.verb}
:'');
const screen =
routes[parseUrl]? routes[parseUrl]: Error404Screen;
const main= document.getElementById("main-container");
main.innerHTML = screen.render();
};
window.addEventListener('load',router);
window.addEventListener('hashchange',router);
from node-javascript-ecommerce.
Related Issues (13)
- dashboard
- Stripe Integration?
- Facing some problem in your amazona series need help!
- Cannot find module 'webpack-cli/bin/config-yargs HOT 1
- Facing issue while following step:4 'rm' is not recognized as an internal or external operable program or batch file. HOT 1
- 'babel-node' is not recognized as an internal or external command, operable program or batch file. [nodemon] app crashed - waiting for file changes before starting... HOT 7
- Basir HOT 1
- Part 05-Build URL Router HOT 3
- Uncaught SyntaxError: expected expression, got '<' after npm run build
- Who to contact for security issues
- Productlist route keeps loading HOT 4
- Keeps loading homepage
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from node-javascript-ecommerce.