Save file on FE

This commit is contained in:
2024-09-26 15:43:28 +02:00
parent 9faa212043
commit fcbf4a689f
3 changed files with 50 additions and 7 deletions

View File

@@ -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();
};