S
S
Stepgor2019-01-18 23:49:57
Node.js
Stepgor, 2019-01-18 23:49:57

Why is nothing loaded when processing a request for a page with a changing url?

Does not load anything, namely css and js

app.use(express.static(path.join(__dirname, '/public')));
app.set('view engine', 'ejs');
app.set('views', path.join(__dirname, '/views'));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));

app.get('/get/:id', (req, res)=>{
  res.render('get');
})

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
ski28, 2019-01-19
@ski28

I have so

app.set("view engine", "ejs");
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json());
app.use(express.static(__dirname + "/public"));

In public, there should be such folders as images,javascripts,stylesheets
In ejs, paths to js and css without /public
Example: "/stylesheets/style.css"

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question