feat: daily motto
This commit is contained in:
@@ -173,3 +173,28 @@ export async function uploadAvatar(avatar, jwt) {
|
||||
const data = await response.json();
|
||||
return data;
|
||||
}
|
||||
|
||||
export async function generateMotto(jwt) {
|
||||
try {
|
||||
const response = await fetch('/api/motto', {
|
||||
headers: {
|
||||
'Authorization': `Bearer ${jwt}`,
|
||||
},
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
if (response.status === 401) {
|
||||
unauthRedirectToLogin();
|
||||
return;
|
||||
}
|
||||
const error = await response.json();
|
||||
throw new Error(error.error || 'Generating motto failed');
|
||||
}
|
||||
|
||||
const data = await response.json();
|
||||
return data.motto;
|
||||
} catch {
|
||||
console.error('Error generating motto:', error);
|
||||
throw new Error('Failed to generate motto');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user