I have a custom hook that gets file data from the cache api based on an url. The hook works fine.
Problem is that I get a response back and I need to parse this data before I can use the fabric tag picker. and I also only want to parse that data when the user starts typing. I know that the prop "filterSuggestedTags" accepts a promise like call and we can fetch data before there.
You will see that I am using a fetch inside the filterSuggestedTags and that ensures to fetch the data from the url before showing the results, plus it shows the loader as well: https://codepen.io/deleite/pen/MWjBMjY?editors=1111
So given the code below and the fact that my useCache gives my a fetch response as state:
const filterSuggestedTags = async (filterText: string, tagList: ITag[]) => {
if (filterText) {
// how can I await the response state? before I can parse the data
return (await /* resp should be the state from the custom hook*/ resp.json()).map(item => ({ key: item.id, name: item.title }));
} else return []
};