adrema/resources/js/composables/useSearch.js

23 lines
561 B
JavaScript
Raw Normal View History

2024-01-28 11:42:32 +01:00
import {inject} from 'vue';
export default function useSearch() {
const axios = inject('axios');
2024-01-29 01:37:28 +01:00
async function search(text, filters = [], options = {}) {
2024-01-28 11:42:32 +01:00
var response = await axios.post(
2024-01-28 19:14:12 +01:00
'/indexes/members/search',
2024-01-28 11:42:32 +01:00
{
q: text,
filter: filters,
2024-01-29 01:37:28 +01:00
...options,
2024-01-28 11:42:32 +01:00
},
{headers: {Authorization: 'Bearer ' + document.querySelector('meta[name="meilisearch_key"]').content}}
);
return response.data;
}
return {
search,
};
}