Closed Marco-Ca closed 3 years ago
<title>.js
under server/routes/
example wedding.js
var express = require('express');
var router = express.Router();
//insert codes here
module.exports = router;
router.get('/', function(req, res, next) {
});
4. Send the response as json
router.get('/', function(req, res, next) {
res.json({
'dining': "After the church ceremony, please proceed to the reception venue. Aperitif will be served on the restaurant's veranda followed by a sit down dinner in the function hall. Please let us know of any special dietary requirements you may have. ",
'dresscode': "Dress Code is semi-formal. Suit and tie. Cocktail dress. Dress real pretty, dress real fine, dress for comfort, dress for fun. 'Cause it's a party, when all's said and done. "
})
});
5. go to `app.js`
6. declare the newly created route based on the filename and add it on the middlewares (middlewares lahat ng may app.use)
`var wedding = require('./routes/wedding');`
`app.use('/wedding', wedding);`
Those lines should come from backend and not hardcoded. For reference, check
Home.jsx
andserver/routes/couple.js
https://github.com/maya-salcedo/Wedding-Invitation-React/blob/f0e717fe42e5896627fcbd1d73f270d22cf7bd15/src/components/Wedding.jsx#L15-L42