random story selector

This commit is contained in:
Stefan Hardegger
2025-08-13 14:48:40 +02:00
parent 142d8328c2
commit 4ab03953ae
5 changed files with 280 additions and 1 deletions

View File

@@ -192,6 +192,22 @@ export const storyApi = {
});
return response.data;
},
getRandomStory: async (filters?: {
searchQuery?: string;
tags?: string[];
}): Promise<Story | null> => {
try {
const response = await api.get('/stories/random', { params: filters });
return response.data;
} catch (error: any) {
if (error.response?.status === 204) {
// No content - no stories match filters
return null;
}
throw error;
}
},
};
// Author endpoints