Sending two arrays with axios?

  • 0
    you need to send two arrays to the server, if I send them separately then everything works.
    , there are no errors, it does not accept anything on the server and does not display errors, the content-type application / json even installed maxContentLength: Infinity,
    maxBodyLength: Infinity,
    still nothing works together, but is sent separately, that is, if one key, one array
    this is how axios.post works (url, {'key': 'array'})
    that doesn't work axios.post (url, {'key': 'array', 'key': 'array'}
    JavaScript Fynn Blackwell, Mar 30, 2019

  • 1 Answers
  • 0
    put indices on the keys

    axios.post(url,{'ключ1':'массив','ключ2':'массив'})




    but you can also wrap it in payload / data

    const arr1 = <your_first_array>;
    const arr2 = <your_second_array>;
    const payload = { arr1, arr2 };
    axios.post(url,{ payload });
    Lilah Waters

Your Answer
To place the code, please use CodePen or similar tool. Thanks you!