GASについて構築

This commit is contained in:
ry.yamafuji 2025-12-07 18:41:02 +09:00
parent bf772ed9f4
commit 42f3a60e0d
2 changed files with 26 additions and 0 deletions

9
examples/apiGet.js Normal file
View File

@ -0,0 +1,9 @@
function callApiExample() {
const url = "https://jsonplaceholder.typicode.com/todos/1";
const response = UrlFetchApp.fetch(url);
const data = JSON.parse(response.getContentText());
const sheet = SpreadsheetApp.getActiveSheet();
sheet.getRange(1, 1).setValue(data.title); // A1 に API のタイトルを書く
}

17
examples/apiPost.js Normal file
View File

@ -0,0 +1,17 @@
function postApiExample() {
const url = "https://example.com/api";
const payload = {
name: "Yamada",
age: 30
};
const options = {
method: "post",
contentType: "application/json",
payload: JSON.stringify(payload)
};
const response = UrlFetchApp.fetch(url, options);
Logger.log(response.getContentText());
}