🐸 Rybbit - open-source and privacy-friendly alternative to Google Analytics that is 10x more intuitive.
Enhance `authedFetch` function to process array parameters for backend JSON parsing. Updated parameter handling to convert arrays into JSON strings, ensuring compatibility with backend requirements and improving data transmission integrity.
Bill Yang1ea080697753
diff --git a/client/src/api/utils.ts b/client/src/api/utils.tsindex 18493df83..3e09eca47 100644--- a/client/src/api/utils.ts+++ b/client/src/api/utils.ts@@ -68,13 +68,26 @@ export async function authedFetch<T>(): Promise<T> {const fullUrl = url.startsWith("http") ? url : `${BACKEND_URL}${url}`;+ // Process params to handle arrays correctly for backend JSON parsing+ let processedParams = params;+ if (params) {+ processedParams = { ...params };+ Object.entries(processedParams).forEach(([key, value]) => {+ if (Array.isArray(value)) {+ // Convert arrays to JSON strings for backend parsing+ processedParams![key] = JSON.stringify(value);+ }+ });+ }+try {const response = await axios({url: fullUrl,- params,+ params: processedParams,withCredentials: true,...config,});+return response.data;} catch (error: any) {if (error?.response?.data?.error) {