What makes request payload an Object Object?

  • 0
    Hello everyone!
    I make a request to the server that should send id and rating
    the code looks like this
    const like = document.querySelectorAll('.like');
        like.forEach(item => {
            item.addEventListener('click', (e) => {
                const fAction = e.target.dataset.act,
                    // TODO
                      thisParId = e.target.dataset.id;
                fetch(fAction, {
                    method: 'POST',
                    headers: {
                        'Content-Type': 'application/json',
                        'X-CSRF-Token': globalData.token,
                    body: {
                        review_id: thisParId,
                        rating: 'like',

    here is the network

    why is the request payload object object and why is the request payload and not the form data
    JavaScript Jasper Moss, Dec 5, 2019

  • 1 Answers
  • 0
    In body you can pass

    1. String (for example, in JSON format),

    2. FormData object to send data as form / multipart,

    3. Blob / BufferSource for sending binary data,

    4. URLSearchParams for sending data in x-www-form-urlencoded encoding, rarely used.



    body: JSON.stringify (data)

    why request payload and not form data
    - it depends on the headers
    Nicholas Warren

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