This is an axios POST request in my React project. labelIDs
is a long array whose length is around 8000.
axios.post('http://localhost:3000/api/filter', {
'ids': labelIDs,
'like_ratio_range': ["0", "1"]
})
I've tried body-parser
but it didn't solve the problem. Any idea how to config axios post body limit?
Or should this API be better designed?
The solution to this problem lies within body parser and how your middleware is set up. Body-parser's limit option will only take in effect if your content-type and type option match. It looks like you're sending regular json to the server, your bodyparser middleware should look something like this.
var express = require("express");
var bodyParser = require("body-parser");
var app = express();
app.use(bodyParser.json({limit: '100kb'}));
If the payload is still too large, increment the bodyParser.json() limit option. Try '200kb', try '300kb'. 100kb shoudld be enough though.
If this bodyParser middleware does not work, please show your body-parser middleware.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With