The “Payload Too Large” error appears when the size of data sent to the server exceeds the limit supported by the server. This limit is often configured to prevent DDoS attacks and to protect server resources.
AxiosError {message: ‘Request failed with status code 413’, name: ‘AxiosError’, code: ‘ERR_BAD_REQUEST’, config: {…}, request: XMLHttpRequest, …}
POST http://localhost:3778/addnewpost 413 (Payload Too Large)
how to fix?
In server.js
app.use(express.json({ limit: "5mb" })); //1mb-50mb app.use(bodyParser.json({ limit: "1mb" })); //1mb-50mb
For Express.js, you can use middleware like express.json({ limit: ’50mb’ }) to increase the limit
After increasing the payload size limit on the server it will work