Need to pass huge data as params in post method in NODE js using request npm

My node application, I need to pass the huge data (18000 objects ) in post method to other node API using request NPM as below.

import request from 'request';

// dataPayCode has 18000 objects [ { id:1, test: 'test' }, ..........]
request.post({url:apiURLGM + 'api/migration/paycode', json: dataPayCode}, function(err,httpResponse,body){
    console.log(body);
});

I am getting the error "request entity too large\n at new ExtendableError"

What should I do to pass the such as huge data as the params in post method?

Any best solution / suggestion pls?

728x90

1 Answers Need to pass huge data as params in post method in NODE js using request npm

For this point, you can increase request body size, but, this is a bad way, also you can slice request too small parts, and I think this is the best solution.

Increasing request body size for NGINX. add the line below to your configuration.

client_max_body_size 100m;

http://nginx.org/en/docs/http/ngx_http_core_module.html#client_max_body_size

P.S. I still recommend slice request to small parts.

4 months ago