简体   繁体   中英

how to link pages in node.js

hello I am new to nodejs and I wants to link pages in node.js but it says Cannot GET /crud/create, a folder named "crud" has two files in it: index.ejs, create.ejs I write this code to get the page, but only index page is showing

  app.get('/crud', (req, res) => res.render('crud'))

at index page when I click on create new than it says cannot get , I am using this link to go on create page:

  <a href="/crud/create" class="btn btn-outline-success my-2 my-sm-0">Create New</a> 

I make a seprate path but all in vain sometimes it shows error and some time remains on same page

   app.get('/crud/create', (req, res) => res.render('create')) 
   app.get('/create', (req, res) => res.render('create'))

You need to create a route that points to /crud/create in order for your tag to work.

Something like this

app.get('/crud/create', (req, res) => res.render('crud create'))

https://expressjs.com/en/guide/routing.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM