feat: Implement e-learning classroom with video playback, progress tracking, and quiz functionality, alongside new course and category composables and Thai localization.
This commit is contained in:
parent
9232b6a21d
commit
4c575dc734
5 changed files with 570 additions and 169 deletions
|
|
@ -73,6 +73,24 @@ export const useCategory = () => {
|
|||
}
|
||||
} catch (err: any) {
|
||||
console.error('Fetch categories failed:', err)
|
||||
|
||||
// Retry logic for 429 Too Many Requests
|
||||
if (err.statusCode === 429 || err.status === 429) {
|
||||
await new Promise(resolve => setTimeout(resolve, 1500)); // Wait 1.5s
|
||||
try {
|
||||
const retryRes = await $fetch<CategoryResponse>(`${API_BASE_URL}/categories`, {
|
||||
method: 'GET',
|
||||
headers: token.value ? { Authorization: `Bearer ${token.value}` } : {}
|
||||
})
|
||||
const cats = retryRes.data?.categories || []
|
||||
categoriesState.value = cats
|
||||
isLoaded.value = true
|
||||
return { success: true, data: cats, total: retryRes.data?.total || 0 }
|
||||
} catch (retryErr) {
|
||||
console.error('Retry fetch categories failed:', retryErr)
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
success: false,
|
||||
error: err.data?.message || err.message || 'Error fetching categories'
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue