Restructure progress
This commit is contained in:
23
src/lib/google/sheets/client.ts
Normal file
23
src/lib/google/sheets/client.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
// Client-side Sheets functions (use fetch to call protected API endpoints)
|
||||
|
||||
/**
|
||||
* Fetch recent spreadsheets via protected endpoint
|
||||
*/
|
||||
export async function getRecentSpreadsheetsClient(refreshToken: string, limit: number = 10) {
|
||||
const response = await fetch(`/private/api/google/sheets/recent?limit=${limit}`, {
|
||||
headers: { Authorization: `Bearer ${refreshToken}` }
|
||||
});
|
||||
if (!response.ok) throw new Error('Failed to fetch recent sheets');
|
||||
return await response.json();
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch spreadsheet data via protected endpoint
|
||||
*/
|
||||
export async function getSpreadsheetDataClient(refreshToken: string, sheetId: string, range: string = 'A1:Z10') {
|
||||
const response = await fetch(`/private/api/google/sheets/${sheetId}/data?range=${encodeURIComponent(range)}`, {
|
||||
headers: { Authorization: `Bearer ${refreshToken}` }
|
||||
});
|
||||
if (!response.ok) throw new Error('Failed to fetch spreadsheet data');
|
||||
return await response.json();
|
||||
}
|
||||
Reference in New Issue
Block a user