Complete the code to set a JSON body size limit of 1mb in Express.
app.use(express.json({ limit: '[1]' }));The limit option accepts a string like '1mb' to set the max request body size.
Complete the code to set a URL-encoded body size limit of 500kb in Express.
app.use(express.urlencoded({ extended: true, limit: '[1]' }));The limit option for express.urlencoded sets the max size. '500kb' means 500 kilobytes.
Fix the error in this code that tries to limit JSON body size to 2mb.
app.use(express.json({ limit: [1] }));The limit value must be a string with quotes, like '2mb'. Without quotes, it causes an error.
Fill both blanks to limit JSON and URL-encoded bodies to 1mb in Express.
app.use(express.json({ limit: '[1]' }));
app.use(express.urlencoded({ extended: true, limit: '[2]' }));Both express.json and express.urlencoded accept size limits as strings. '1mb' and '1000kb' are equivalent.
Fill all three blanks to create an Express app limiting JSON to 2mb, URL-encoded to 1mb, and text bodies to 500kb.
app.use(express.json({ limit: '[1]' }));
app.use(express.urlencoded({ extended: true, limit: '[2]' }));
app.use(express.text({ limit: '[3]' }));Each middleware sets a size limit string: JSON to '2mb', URL-encoded to '1mb', and text to '500kb'.