handle expected empty response

This commit is contained in:
Simon 2025-02-17 17:23:26 +07:00
parent c18090e169
commit 59cc177913
No known key found for this signature in database
GPG Key ID: 2C15AA5E89985DD4
1 changed files with 8 additions and 1 deletions

View File

@ -55,8 +55,15 @@ const APIClient = async (
throw new Error('Forbidden: Access denied.');
}
// Try parsing response data
let data;
// expected empty response
if (response.status === 204) {
data = null;
return data;
}
// Try parsing response data
try {
data = await response.json();
} catch (error) {