Http Get Request with Axios

Asked

Viewed 1,730 times

0

1 answer

3


That’s simple, just declare it so

<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>
  • I thought it was simple, I just didn’t know if it was parameters and Google wasn’t helping me rsrs. If I want to pass more parameters, I can add more elements to this property params ?

  • 1

    yes, just put comma deletado: this.checkbox, outroParams: this.param and etc

  • Perfect guy, thank you so much! :)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.