title: How do I send an array with fetch? (Javascript)
body: <p>I'm trying to send an array using fetch that looks like this:</p>
  
  <pre><code>{"cards":[[189,2],[211,2],[238,2],[778,2],[985,2],[1008,2],[1073,2],[1171,2],[48886,2],[49161,2],[49164,2],[49184,1],[49356,2],[50372,2],[51722,1],[52422,2]],"heroes":[1066],"format":2}
  </code></pre>
  
  <p>Here is what I am trying: </p>
  
  <pre><code> getCardsForDeck = deck =&gt; {
      var stringifiedDeck = JSON.stringify(deck);
      console.log("stringifiedDeck:" + stringifiedDeck);
      fetch(`http://localhost:3001/api/getCardsForDeck`, {
        method: "PUT",
        body: stringifiedDeck
      })
        .then(cards =&gt; cards.json())
        .then(res =&gt; this.setState({ cards: res.cards }));
    };
  </code></pre>
  
  <p>I am getting an error though:</p>
  
  <pre><code>Unhandled Rejection (SyntaxError): Unexpected token &lt; in JSON at position 0
  </code></pre>
  
  <p>How do I send this data if not with JSON.stringify() or do I have to edit the data to remove the brackets?</p>
  
  <p>Upon checking the api in the network tab it gives me this:</p>
  
  <pre><code>     SyntaxError: Unexpected token o in JSON at position 1
  [0]     at JSON.parse (&lt;anonymous&gt;)
  [0]     at parse (C:\Users\User\projects\webapp\deck-editor\backend\node_modules\body-parser\lib\types\json.js:89:19)
  [0]     at C:\Users\User\projects\webapp\deck-editor\backend\node_modules\body-parser\lib\read.js:121:18
  [0]     at invokeCallback (C:\Users\User\projects\webapp\deck-editor\backend\node_modules\raw-body\index.js:224:16)
  [0]     at done (C:\Users\User\projects\webapp\deck-editor\backend\node_modules\raw-body\index.js:213:7)
  [0]     at IncomingMessage.onEnd (C:\Users\User\projects\webapp\deck-editor\backend\node_modules\raw-body\index.js:273:7)
  [0]     at IncomingMessage.emit (events.js:194:15)
  [0]     at endReadableNT (_stream_readable.js:1125:12)
  [0]     at process._tickCallback (internal/process/next_tick.js:63:19)
  [0] SyntaxError: Unexpected token o in JSON at position 1
  [0]     at JSON.parse (&lt;anonymous&gt;)
  [0]     at parse (C:\Users\User\projects\webapp\deck-editor\backend\node_modules\body-parser\lib\types\json.js:89:19)
  [0]     at C:\Users\User\projects\webapp\deck-editor\backend\node_modules\body-parser\lib\read.js:121:18
  [0]     at invokeCallback (C:\Users\User\projects\webapp\deck-editor\backend\node_modules\raw-body\index.js:224:16)
  [0]     at done (C:\Users\User\projects\webapp\deck-editor\backend\node_modules\raw-body\index.js:213:7)
  [0]     at IncomingMessage.onEnd (C:\Users\User\projects\webapp\deck-editor\backend\node_modules\raw-body\index.js:273:7)
  [0]     at IncomingMessage.emit (events.js:194:15)
  [0]     at endReadableNT (_stream_readable.js:1125:12)
  [0]     at process._tickCallback (internal/process/next_tick.js:63:19)
  </code></pre>