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