title: How to set parameters in a get request from reactJS
body: <p>Maybe its a very newbie question for here but i spend a lot of time to see a good approach for doing this and i didn't find convenient answer. I am trying to make a simple call to a rest api and i want to pass a value with the GET request appended to the string. like url/foo where foo is the parameter. I have a query variable that i want to append to the end of the url string for the get request. Thank you in advance.</p>
  
  <pre><code>class About extends React.Component {
  
      constructor(props) {
          super(props);
          this.state = {
              products: [],
              filteredItems: [],
              user: {},
              query: '' &lt;-- query variable to be appended to the end of the get request
          };
  
      }
  
  
  
      componentDidMount() {
  
          fetch(`'myurl/${this.state.query}'`) &lt;-- i want to append the variable at the end of the string ??
              .then(res =&gt; res.json())
              .then((result) =&gt; {
                      console.log(result);
                      this.setState({
                          products: result,
                          filteredItems: result
                      });
                  }
              )
      }
  
      queryChange = (evt) =&gt; {
          this.setState({query: evt.target.value}) &lt;-- update the variable state from an event
      }
  
  
  
  
  </code></pre>