0
0
Expressframework~10 mins

Request size limits in Express - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to set a JSON body size limit of 1mb in Express.

Express
app.use(express.json({ limit: '[1]' }));
Drag options to blanks, or click blank then click option'
A1mbs
B1mb
C1000kb
Done_mb
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect units like '1mbs' or 'one_mb'.
Passing a number without quotes.
2fill in blank
medium

Complete the code to set a URL-encoded body size limit of 500kb in Express.

Express
app.use(express.urlencoded({ extended: true, limit: '[1]' }));
Drag options to blanks, or click blank then click option'
A500kb
B500mb
C0.5mb
D500
Attempts:
3 left
💡 Hint
Common Mistakes
Using '500' without units causes no size limit.
Using '500mb' is too large for this example.
3fill in blank
hard

Fix the error in this code that tries to limit JSON body size to 2mb.

Express
app.use(express.json({ limit: [1] }));
Drag options to blanks, or click blank then click option'
A'2mb'
B2
C"2mb"
D2mb
Attempts:
3 left
💡 Hint
Common Mistakes
Passing 2mb without quotes causes a syntax error.
Passing a number like 2 means 2 bytes, which is too small.
4fill in blank
hard

Fill both blanks to limit JSON and URL-encoded bodies to 1mb in Express.

Express
app.use(express.json({ limit: '[1]' }));
app.use(express.urlencoded({ extended: true, limit: '[2]' }));
Drag options to blanks, or click blank then click option'
A1mb
B1000kb
C1kb
D10mb
Attempts:
3 left
💡 Hint
Common Mistakes
Using '1kb' is too small for typical requests.
Using '10mb' is larger than requested.
5fill in blank
hard

Fill all three blanks to create an Express app limiting JSON to 2mb, URL-encoded to 1mb, and text bodies to 500kb.

Express
app.use(express.json({ limit: '[1]' }));
app.use(express.urlencoded({ extended: true, limit: '[2]' }));
app.use(express.text({ limit: '[3]' }));
Drag options to blanks, or click blank then click option'
A2mb
B1mb
C500kb
D5mb
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up the size limits for each parser.
Using numbers without quotes.