GASについて構築
This commit is contained in:
parent
bf772ed9f4
commit
42f3a60e0d
9
examples/apiGet.js
Normal file
9
examples/apiGet.js
Normal 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
17
examples/apiPost.js
Normal 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());
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user