diff --git a/app/src/services/api.js b/app/src/services/api.js index dc8c1df..626f684 100644 --- a/app/src/services/api.js +++ b/app/src/services/api.js @@ -47,17 +47,16 @@ export const saveFileContent = async (workspaceName, filePath, content) => { body: content, } ); - return response.text(); + return response.json(); }; export const deleteFile = async (workspaceName, filePath) => { - const response = await apiCall( + await apiCall( `${API_BASE_URL}/workspaces/${workspaceName}/files/${filePath}`, { method: 'DELETE', } ); - return response.text(); }; export const getWorkspace = async (workspaceName) => { @@ -119,17 +118,13 @@ export const lookupFileByName = async (workspaceName, filename) => { }; export const updateLastOpenedFile = async (workspaceName, filePath) => { - const response = await apiCall( - `${API_BASE_URL}/workspaces/${workspaceName}/files/last`, - { - method: 'PUT', - headers: { - 'Content-Type': 'application/json', - }, - body: JSON.stringify({ filePath }), - } - ); - return response.json(); + await apiCall(`${API_BASE_URL}/workspaces/${workspaceName}/files/last`, { + method: 'PUT', + headers: { + 'Content-Type': 'application/json', + }, + body: JSON.stringify({ filePath }), + }); }; export const getLastOpenedFile = async (workspaceName) => { diff --git a/app/src/services/authApi.js b/app/src/services/authApi.js index 9b1ae31..1144f0c 100644 --- a/app/src/services/authApi.js +++ b/app/src/services/authApi.js @@ -49,13 +49,17 @@ export const apiCall = async (url, options = {}) => { throw new Error('Authentication failed'); } - if (!response.ok) { + if (!response.ok && response.status !== 204) { const errorData = await response.json().catch(() => null); throw new Error( errorData?.message || `HTTP error! status: ${response.status}` ); } + if (response.status === 204) { + return null; + } + return response; } catch (error) { console.error(`API call failed: ${error.message}`);