Include metadata of getItems query #26
-
Hi, I'm not sure what is the best way to implement this but I think meta data is needed for paging when quering a set of data. How did you guys handle this right now? |
Beta Was this translation helpful? Give feedback.
Replies: 6 comments 8 replies
-
Currently we have the page param which you can provide. What do you mean with "meta data" |
Beta Was this translation helpful? Give feedback.
-
So the |
Beta Was this translation helpful? Give feedback.
-
Is there any way to do pagination based on this module? |
Beta Was this translation helpful? Give feedback.
-
@kieusonlam Can you mark this as answered please? |
Beta Was this translation helpful? Give feedback.
-
Sorry, I have a stupid question const { getItems } = useDirectusItems()
const fetchResults = async (i) => {
try {
const results = await getItems({
collection: 'fagui',
params: {
search: i,
limit: 10,
page: 1,
meta: 'filter_count',
},
})
console.log('Results:', results)
}
catch (e) {}
@@@}
await fetchResults(keyword.value) Am I missing something? |
Beta Was this translation helpful? Give feedback.
-
sorry , It may be that I did not express it clearly Although the meta parameter can be used. but data:[.....] how can i get const fetchPosts = async (i) => {
const { data: blog }: any = await useFetch('/items/fagui/', {
baseURL: useRuntimeConfig().public.baseURL,
headers: { Authorization: `Bearer ${useRuntimeConfig().public.token}` },
params: {
search: i as string,
limit: 10 as number, // maximum returned
page: 1,
meta: 'filter_count',
},
})
// the maximum number of items that will be returned
console.log('limit:', blog.value.data.length)
// like this ,i can get meta.filter_count
console.log('total:', blog.value.meta.filter_count)
}
fetchPosts(keyword) |
Beta Was this translation helpful? Give feedback.
@kieusonlam Can you mark this as answered please?