title: How to pass an argument to a function in my backend using .fetch()? ReactJS + Node
body: <p>So I want to pass an integer argument to a function in my backend and have it return the data. I've been looking through the documentation and it seems like there might not be a way for me to pass an argument via the code I currently have. I just want second opinions before I consider using a different approach.</p>
  <p>Frontend:</p>
  <pre><code>//is there a way for me to pass num to req in the backend?
  newMarker = (num) =&gt; {
        fetch('/api/getMarkers')
        .then(res =&gt; res.json())
        .then(mark =&gt; this.setState({ markers: mark }))
    }
  </code></pre>
  <p>Backend:</p>
  <pre><code>//function where argument needs to be passed to, used in the request below
  const fillNewMarker = async function fillNewMarker(num){
    let temp;
    let data;
    await populartimes(markers[num].placeID)
    .then(out =&gt; {data = out; temp = 'Currently ' + data.now.currently + ' full.'})
    .catch(() =&gt; {temp = 'There is currently no data available.'});
    markers[num].busy = temp;
  }
  
  //request
  //i need num to be passed to req here
  app.get('/api/newMarker', async (req,res) =&gt; {
      await fillNewMarker(req);
      console.log('Retrieve Data For New Marker Complete')
      var mark = markers;
      res.json(mark);
      console.log('Sent Markers');
      console.log(markers);
  })
  </code></pre>
  <p>I've been working for quite a while so my brain is a little bit fried, there might be a really obvious solution that I have missed - if so, I apologize for my ignorance. Help is appreciated! TIA :)</p>
  <p>Fix Attemp #1:</p>
  <pre><code>//Front end
    newMarker = (num) =&gt; {
        fetch('/api/newMarker', {
          method: 'POST',
          headers: {
            'Content-Type': 'application/json'
            // 'Content-Type': 'application/x-www-form-urlencoded',
          },
          body: JSON.stringify(num) // body data type must match &quot;Content-Type&quot; 
          header
        })
        .then(res =&gt; res.json())
        .then(mark =&gt; this.setState({ markers: mark }))
    }
  
  //method call via button
  onButtonClick(){
    this.newMarker(6)
    //6 for testing
  }
  
  //backend
  app.get('/api/newMarker', async (req,res) =&gt; {
      console.log('Request received')
      await fillNewMarker(req.body.num);
      console.log('Retrieve Data For New Marker Complete')
      var mark = markers;
      res.json(mark);
      console.log('Sent Markers');
      console.log(markers);
  })
  </code></pre>