E
E
Eugene2019-04-04 23:59:33
JavaScript
Eugene, 2019-04-04 23:59:33

How to make dynamic routing with two parameters?

Objective:
1. Have a URL like: /books/tolstoy
2. In Express.js, have this path be processed through two dynamic variables: /:section/:author (for example)
Option: /what/:section/who/:author is not suitable .
How to do it? Make CNC. In PHP, I remember this was done through .htaccess.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
E
Eugene, 2019-04-05
@Shagfey

Understood.
The error was as follows:
1. Styles were loaded like this 'styles/style.css'
2. And the inclusion of statics was like this: app.use(express.static('resources'))
Solution:
1. Styles like this: '/static/styles /etc.css'
2. Static like this: 'app.use('/static', express.static(__dirname + 'resources', {fallthrough: false}))'
Reason:
As I understand the styles were pulled to the address immediately after the first /, so they were loaded incorrectly. By specifying a specific folder, this problem is gone.

H
hzzzzl, 2019-04-05
@hzzzzl

maybe the problem is somewhere else, otherwise it works
5ca714f9c85bc476684464.png

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question