const createFetchStore = (fetchActionName, baseUrl) => create(set => {
result: null,
loading: false,
error: null,
[fetchActionName]: async (id)=> {
try {
set({ loading: true })
const result = await (await fetch(`${baseUrl}/${id}`)).json()
set({ loading: false, result })
} catch(error) {
set({ loading: false, error })
}
},
});