| Level Navigation: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10⚡ | 11⚡ | 12⚡ | 13⚡ | 14⚡ | 15 | 16 | 17 | 18⚡ | 19 | 20 |
User Story: As a developer, I want to create a server route so that I can receive and process the form data when users submit their Mad Libs.
Create a server route to handle form submission and process the form data.
/create-mad-libs route using app.get()req.queryNeed help with routes? Check out these snippets:
app.get('/create-mad-libs', (req, res) => {})req.query.fieldName to access form data, where fieldName is the “name” of the input in the form. For example for “properNoun1”, you would have req.query.properNoun1.console.log() to debug form dataapp.get('/create-mad-libs', (req, res) => {
// Access form data here
console.log('Form submitted!');
res.send('Form received!');
});
app.get('/create-mad-libs', (req, res) => {
const name = req.query.name;
const adjective = req.query.adjective1;
console.log('Name:', name);
console.log('Adjective:', adjective);
res.send('Data received!');
});