FAQ: Learn Express Routes - Sending A Response

This community-built FAQ covers the “Sending A Response” exercise from the lesson “Learn Express Routes”.

Paths and Courses
This exercise can be found in the following Codecademy content:

Web Development

Learn Express

FAQs on the exercise Sending A Response

Join the Discussion. Help a fellow learner on their journey.

Ask or answer a question about this exercise by clicking reply (reply) below!

Agree with a comment or answer? Like (like) to up-vote the contribution!

Need broader help or resources? Head here.

Looking for motivation to keep learning? Join our wider discussions.

Learn more about how to use this guide.

Found a bug? Report it!

Have a question about your account or billing? Reach out to our customer support team!

None of the above? Find out where to ask other questions here!

Please explain what const { seedElements} = require('./utils'); is and what does it do in relation to:

const expressions = [];
seedElements(expressions, 'expressions');


Hi there,
in app.js we find this:
const { seedElements } = require(’./utils’);

It appears to import a single property of the exported module (object) from utils.js:
module.exports = {
createElement: createElement,
getIndexById: getIndexById,
getElementById: getElementById,
updateElement: updateElement,
seedElements: seedElements,

It is smart but was not covered in the module course so it’s all new to me and it appears to use the bracket syntax introduced by ES6 for named exports/imports but does not use the import keyword.

Is this syntax valid in ES5?

If not and it is a ES6 syntax, then why use the require() function rather than the import…from keywords (import { seedElements } from ./utils), making a mix of the two syntaxes?

Since the module.exports example is confusing with properties’ names and values bearing the exact same designation, I’m left to suppose that in const { seedElements }, seedElements is the property’s name, used as a key to locate and return its value. Am I correct?

1 Like


In this exercise “Learn Express” (code snippet below), what is the point to call app.use() twice?

const express = require(‘express’);
const app = express();
const { seedElements } = require(’./utils’);

// Serves Express Yourself website

const PORT = process.env.PORT || 4001;
// Use static server to serve the Express Yourself Website

const expressions = ;
seedElements(expressions, ‘expressions’);

// Get all expressions
app.get(’/expressions’, (req, res, next) => {
// console.log(req);

app.listen(PORT, () => {
console.log(Listening on port ${PORT});

1 Like