How do I split the package when js post submits the data?

question:
foresee a problem during development, that is, when I post submit data, multiple sub-packages are combined into a large package. Now the backend service has a limit. If the package exceeds 30 kb, split it. For example, this package is made up of 8 sub-packages. If it is greater than 30 kb, it will be divided into four or four equal parts first, and the package will be divided into two parts, each with four packages. If these four packets are still more than 30kb, then split them, and so on, until they meet the requirements;

give an example:

   var datas = {
    school:"",
    conts:[{
      name:"andy",
      age:19
    },{
      name:"jack",
      age:40
    },{
      name:"lcuy",
      age:23
    },{
      name:"chen",
      age:35
    },{
      name:"heh",
      age:28
    }]
  }

among them, the value of conts is made up of every other subpackage, and it is processed; ladies and gentlemen, do you have any suggestions?

Mar.02,2021

has been solved;
has written a recursive function


that can make the interception of the array go around like this.

Menu