0

When api work on less data $http.post() gets response but when working with large data the api takes time (like 2-3 min) but on front-end angularjs do not get any response. I check on the backend(nodejs) the code is working and also returns data which does not get response on angular side while the api takes time to return else when working on less data it works fine.

$http.post('/campaign/addInventorytocampaign', params).then(function (addInventorydata) {
        console.log("addInventorydata  = ",addInventorydata.data);});

The error i get in console is

angular.min.js:11756 POST http://localhost:3000/campaign/addInventorytocampaign net::ERR_EMPTY_RESPONSE

While the backend is still in process

is there any way/correct way to do it

Anuj Kumar Pal
  • 142
  • 2
  • 12
  • Did you try to add a catch block in your request to see if you get an error? Like this: `$http.post('url', params).then(function(data) { /* do sthg with data */ }).catch(function (error) { /* do sthg with error */ })` – SylvainF Mar 07 '19 at 10:59
  • @SylvainF It gives error in console [angular.min.js:11756 POST http://localhost:3000/campaign/addInventorytocampaign net::ERR_EMPTY_RESPONSE] while on server side the function is still in process – Anuj Kumar Pal Mar 07 '19 at 12:07
  • It could be related to what is your data encoded in. You should look to this thread to see if changing headers resolve your issue: https://stackoverflow.com/questions/11442632/how-can-i-post-data-as-form-data-instead-of-a-request-payload – SylvainF Mar 07 '19 at 13:16

0 Answers0