export default {

  methods: {
    fetchOptions (url,search, loading,callback) {
      if (search.length) {
        loading(true);
        this._search(url,loading, search, callback);
      }
    },

    _search: _.debounce((url,loading, search,callback) => {
      fetch(
      `${url}?q=${escape(search)}`).
      then(res => {
        res.json().then(json => callback(json));
        loading(false);
      });
    }, 350) 

  },
}