FE Settings integration

This commit is contained in:
2024-09-27 17:54:00 +02:00
parent 3a651ce4d8
commit 840e77fcc0
4 changed files with 72 additions and 8 deletions

View File

@@ -40,4 +40,36 @@ export const saveFileContent = async (filePath, content) => {
}
return await response.text();
};
};
export const fetchUserSettings = async (userId) => {
try {
const response = await fetch(`${API_BASE_URL}/settings?userId=${userId}`);
if (!response.ok) {
throw new Error('Failed to fetch user settings');
}
return await response.json();
} catch (error) {
console.error('Error fetching user settings:', error);
throw error;
}
};
export const saveUserSettings = async (settings) => {
try {
const response = await fetch(`${API_BASE_URL}/settings`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(settings),
});
if (!response.ok) {
throw new Error('Failed to save user settings');
}
return await response.json();
} catch (error) {
console.error('Error saving user settings:', error);
throw error;
}
};