Http Get Request with Axios

0

I need help to make a get for my restAPI by passing parameter (I do not know if that's the way it's called, if I can speak the way I say it, I appreciate it!) .

What I do is call a list in link

  axios.get(' http://localhost:6000/API/Lojas ').then(response => {
              this.data = response.data.Data
           })

I need to do 2 checkbox with values to do a get at this URL:

link < link Deleted = true Deleted = false

How can I do this? Thanks!

    
asked by anonymous 19.10.2017 / 21:08

1 answer

2

This is simple, you just declare it

<script>
   export default{
      data(){
          return{
             checkbox: []
          }
      },
      methods: {
         api(){
            axios.get('http://localhost:6000/API/Lojas', {
                params: {
                   deletado: this.checkbox
                   // Se for falso sera http://localhost:6000/API/Lojas?deletado=false

                   // Se for true será http://localhost:6000/API/Lojas?deletado=true
                }
            })
            .then(response => {
               console.log(response)
            })
            .catch(error => {
                 console.log(error)
            })
         }
      }
   }
</script>
    
19.10.2017 / 21:11