I have this app, where the client has very low upload speed, so I need to compress the JSON they send to the server in order to improve their speed.
I've checked several (probably all) questions on here about pako, gzip, zlib, etc... and can't get them to work for me.
I've tried defining the request like this:
.factory('Form', function ($http, DateUtils) {
return {
save: function(formDTO){
var req = {
method: 'POST',
url: "api/form",
headers: {
'Content-Type': 'application/json',
'Content-Encoding': 'gzip'
},
data: formDTO,
transformRequest: []
};
console.log('in the form.service.js');
return $http(req);
},
load: function(id){
return $http.get("api/form/"+id)
}
}
});
And it basically sends an empty body.
I've tried installing ngPako and doing the request like this:
.factory('Form', function ($http, DateUtils, pako) {
return {
save: function(formDTO){
var newFormDTO = pako.deflate(formDTO, {to: 'string'});
console.log('this is the deflated data', newFormDTO);
console.log('in the form.service.js');
return $http.post("api/form", formDTO);
},
load: function(id){
return $http.get("api/form/"+id)
}
}
And the browser just crashes on me
Is there anyway to compress data with angular?