• Fixing "Error: request entity too large" in body-parser

    We use body-parser module to handle the request body in the Express framework. If you have not configured the BodyParser module properly you might end up getting error 

    "Error: request entity too large"

    To handle this error, you can specify the maximum size of entity in the body-parser module.

    const express = require("express");
    const bodyParser = require("body-parser");
    const app = express();
    // configure bodyparser
    app.use(bodyParser.json({limit: '50mb'}));
    app.use(bodyParser.urlencoded({ extended: false, limit: '50mb' }));

    Configure the file size based on your project requirenment. This will fix the "request entity too large" error.