fixes
This commit is contained in:
@@ -15,10 +15,17 @@ export enum Table {
|
||||
Interest = "mbs9hjauug4eseo",
|
||||
}
|
||||
|
||||
export const getNocoDbConfiguration = () => useRuntimeConfig().nocodb;
|
||||
export const getNocoDbConfiguration = () => {
|
||||
const config = useRuntimeConfig().nocodb;
|
||||
console.log('[nocodb] Configuration URL:', config.url);
|
||||
return config;
|
||||
};
|
||||
|
||||
export const createTableUrl = (table: Table) =>
|
||||
`${getNocoDbConfiguration().url}/api/v2/tables/${table}/records`;
|
||||
export const createTableUrl = (table: Table) => {
|
||||
const url = `${getNocoDbConfiguration().url}/api/v2/tables/${table}/records`;
|
||||
console.log('[nocodb] Table URL:', url);
|
||||
return url;
|
||||
};
|
||||
|
||||
export const getInterests = async () =>
|
||||
$fetch<InterestsResponse>(createTableUrl(Table.Interest), {
|
||||
@@ -41,6 +48,20 @@ export const updateInterest = async (id: string, data: Partial<Interest>, retryC
|
||||
console.log('[nocodb.updateInterest] Updating interest:', id, 'Retry:', retryCount);
|
||||
console.log('[nocodb.updateInterest] Data fields:', Object.keys(data));
|
||||
|
||||
// First, try to verify the record exists
|
||||
if (retryCount === 0) {
|
||||
try {
|
||||
console.log('[nocodb.updateInterest] Verifying record exists...');
|
||||
const existingRecord = await getInterestById(id);
|
||||
console.log('[nocodb.updateInterest] Record exists with ID:', existingRecord.Id);
|
||||
} catch (verifyError: any) {
|
||||
console.error('[nocodb.updateInterest] Failed to verify record:', verifyError);
|
||||
if (verifyError.statusCode === 404 || verifyError.status === 404) {
|
||||
console.error('[nocodb.updateInterest] Record verification failed - record not found');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Create a clean data object that matches the InterestsRequest schema
|
||||
// Remove any properties that are not in the schema or shouldn't be sent
|
||||
const cleanData: Record<string, any> = {};
|
||||
@@ -97,10 +118,16 @@ export const updateInterest = async (id: string, data: Partial<Interest>, retryC
|
||||
console.log('[nocodb.updateInterest] URL:', url);
|
||||
|
||||
try {
|
||||
console.log('[nocodb.updateInterest] Sending PATCH request with headers:', {
|
||||
"xc-token": getNocoDbConfiguration().token ? "***" + getNocoDbConfiguration().token.slice(-4) : "not set"
|
||||
});
|
||||
console.log('[nocodb.updateInterest] Request body:', JSON.stringify(cleanData, null, 2));
|
||||
|
||||
const result = await $fetch<Interest>(url, {
|
||||
method: "PATCH",
|
||||
headers: {
|
||||
"xc-token": getNocoDbConfiguration().token,
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
body: cleanData
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user