mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-04-25 00:36:31 +02:00
chore: linting
This commit is contained in:
parent
11915df97b
commit
73a57589ac
25 changed files with 184 additions and 181 deletions
|
|
@ -161,52 +161,52 @@ class BaseApiService {
|
|||
}
|
||||
}
|
||||
|
||||
// biome-ignore lint/suspicious: Unknown
|
||||
let data;
|
||||
const responseType = mergedOptions.responseType;
|
||||
// biome-ignore lint/suspicious: Unknown
|
||||
let data;
|
||||
const responseType = mergedOptions.responseType;
|
||||
|
||||
try {
|
||||
switch (responseType) {
|
||||
case ResponseType.JSON:
|
||||
data = await response.json();
|
||||
break;
|
||||
case ResponseType.TEXT:
|
||||
data = await response.text();
|
||||
break;
|
||||
case ResponseType.BLOB:
|
||||
data = await response.blob();
|
||||
break;
|
||||
case ResponseType.ARRAY_BUFFER:
|
||||
data = await response.arrayBuffer();
|
||||
break;
|
||||
// Add more cases as needed
|
||||
default:
|
||||
data = await response.json();
|
||||
try {
|
||||
switch (responseType) {
|
||||
case ResponseType.JSON:
|
||||
data = await response.json();
|
||||
break;
|
||||
case ResponseType.TEXT:
|
||||
data = await response.text();
|
||||
break;
|
||||
case ResponseType.BLOB:
|
||||
data = await response.blob();
|
||||
break;
|
||||
case ResponseType.ARRAY_BUFFER:
|
||||
data = await response.arrayBuffer();
|
||||
break;
|
||||
// Add more cases as needed
|
||||
default:
|
||||
data = await response.json();
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Failed to parse response as JSON:", error);
|
||||
throw new AppError("Failed to parse response", response.status, response.statusText);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Failed to parse response as JSON:", error);
|
||||
throw new AppError("Failed to parse response", response.status, response.statusText);
|
||||
}
|
||||
|
||||
// Validate response
|
||||
if (responseType === ResponseType.JSON) {
|
||||
if (!responseSchema) {
|
||||
// Validate response
|
||||
if (responseType === ResponseType.JSON) {
|
||||
if (!responseSchema) {
|
||||
return data;
|
||||
}
|
||||
const parsedData = responseSchema.safeParse(data);
|
||||
|
||||
if (!parsedData.success) {
|
||||
/** The request was successful, but the response data does not match the expected schema.
|
||||
* This is a client side error, and should be fixed by updating the responseSchema to keep things typed.
|
||||
* This error should not be shown to the user , it is for dev only.
|
||||
*/
|
||||
console.error(`Invalid API response schema - ${url} :`, JSON.stringify(parsedData.error));
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
const parsedData = responseSchema.safeParse(data);
|
||||
|
||||
if (!parsedData.success) {
|
||||
/** The request was successful, but the response data does not match the expected schema.
|
||||
* This is a client side error, and should be fixed by updating the responseSchema to keep things typed.
|
||||
* This error should not be shown to the user , it is for dev only.
|
||||
*/
|
||||
console.error(`Invalid API response schema - ${url} :`, JSON.stringify(parsedData.error));
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
return data;
|
||||
} catch (error) {
|
||||
console.error("Request failed:", JSON.stringify(error));
|
||||
throw error;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue