Sunday, July 18, 2021

bodyParser had been deprecated and re-added to express.json.

 Usually we use bodyParser from body-parser library to parse the json object in the express server.

after we upgrade the express library to 4.16. we should receive the following message.

The signature '(options?: OptionsJson & OptionsText & OptionsUrlencoded): NextHandleFunction' of 'bodyParser' is deprecated.ts(6387)

index.d.ts(19, 5): The declaration was marked as deprecated here.

before we use this one to limit the JSON object size.

app.use(bodyParser.urlencoded({limit:'25mb'extended:true}));
app.use(bodyParser.json({limit:'25mb'}));

currently it directly interact with express object

app.use(express.urlencoded({limit:'25mb'extended:true}));
app.use(express.json({limit:'25mb'}));


No comments:

Post a Comment