title: Best Way to Pass Query Parameters to URL Using Axios in Vue?
body: <p>What I am trying to accomplish is when the page first loads I will use Axios using the base URL to pull back a JSON object. I then want to add query parameters to the base URL when a button is clicked. So something along the lines of if the base URL is 'test.com' when the button is clicked a query parameter would be added to the URL and Axios would run again pulling back a different JSON object. So the URL could look something like 'test.com?posttype=new'.</p>
  
  <p>What I am currently doing is on create run Axios with the base URL and when the button is clicked run a method that runs Axios again but this time it adds the query parameters to the URL so in Vue it looks like: </p>
  
  <pre><code> created () {
  
      axios
        .get(this.jobsListURL)
        .then(response =&gt; (this.jobsList = response.data.data))
        .catch(error =&gt; {
          console.log(error)
          this.errored = true
        })
        .finally(() =&gt; this.loading = false)
  
      },
  
    methods: {
      getJobs: function () {
  
      axios
        .get(this.jobsListURL + '?' + this.AxiosParams)
        .then(response =&gt; (this.jobsList = response.data.data))
  
        .catch(error =&gt; {
          console.log(error)
          this.errored = true
        })
  
        .finally(() =&gt; this.loading = false)
    },
  </code></pre>
  
  <p>So in the above example jobsListURL is the base URL for the JSON object and AxiosParams is a method I am  calling to add the parameters to the URL when the button is clicked. So when the button is clicked it is running the getJobs method to rerun Axios using the URL with the parameters. I am not sure if this is the best approach for this or if there is a better way of adding query parameters to the URL and grabbing  the new JSON object this way. </p>
  
  <p>Just looking for some feedback before I go to far down this route to see if there is a better approach for this?</p>