mirror of
https://github.com/lordmathis/lemma.git
synced 2025-11-06 16:04:23 +00:00
Save file on FE
This commit is contained in:
@@ -24,4 +24,20 @@ export const fetchFileContent = async (filePath) => {
|
||||
console.error('Error fetching file content:', error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
export const saveFileContent = async (filePath, content) => {
|
||||
const response = await fetch(`/api/v1/files/${filePath}`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'text/plain',
|
||||
},
|
||||
body: content,
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error('Failed to save file');
|
||||
}
|
||||
|
||||
return await response.text();
|
||||
};
|
||||
Reference in New Issue
Block a user