1 | |
2 |
|
3 | type Gsheets = { |
4 | token: string; |
5 | }; |
6 | export async function main( |
7 | gsheets_auth: Gsheets, |
8 | sheet_id: string, |
9 | spreadsheet_id_1: string, |
10 | spreadsheet_id_2: string, |
11 | ) { |
12 | const token = gsheets_auth["token"]; |
13 |
|
14 | const COPY_TO_URL = `https://sheets.googleapis.com/v4/spreadsheets/${spreadsheet_id_1}/sheets/${sheet_id}:copyTo`; |
15 |
|
16 | const req = { |
17 | destinationSpreadsheetId: spreadsheet_id_2, |
18 | }; |
19 |
|
20 | const response = await fetch(COPY_TO_URL, { |
21 | method: "POST", |
22 | body: JSON.stringify(req), |
23 | headers: { |
24 | Authorization: "Bearer " + token, |
25 | "Content-Type": "application/json", |
26 | }, |
27 | }); |
28 |
|
29 | return await response.text(); |
30 | } |
31 |
|