<template>
  <vue-suggestion :items="items" 
                  v-model="item" 
                  :setLabel="setLabel"
                  :itemTemplate="itemTemplate"
                  @changed="inputChange" 
                  @selected="itemSelected">
  </vue-suggestion>
</template>

<script>
import itemTemplate from './item-template.vue';
export default {
  data () {
    return {
      item: {},
      items: [
       
      ],
      itemTemplate,
    }
  },
  methods: {
    itemSelected (item) {
      this.item = item;
    },
    setLabel (item) {
      return item.computer;
    },
    inputChange (text) {
        axios.get('search/autocomplete', {
                        params: {
                        term: text,
                        }
            })
            .then((response)  => {
                this.items = response.data;
            })
            .catch(function (error) {
                console.log(error);
            });
    },
  },
};
</script>
