maya-salcedo / Wedding-Invitation-React

1 stars 2 forks source link

Wedding.jsx data should come from backend #2

Closed Marco-Ca closed 3 years ago

Marco-Ca commented 3 years ago

Those lines should come from backend and not hardcoded. For reference, check Home.jsx and server/routes/couple.js

https://github.com/maya-salcedo/Wedding-Invitation-React/blob/f0e717fe42e5896627fcbd1d73f270d22cf7bd15/src/components/Wedding.jsx#L15-L42

Marco-Ca commented 3 years ago

Steps in creating a new route

  1. add <title>.js under server/routes/ example wedding.js
  2. declare express boilerplate
    var express = require('express');
    var router = express.Router();
    //insert codes here
    module.exports = router;
  3. add the route, always use '/'
    
    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);`