Example Get and Post requests.

The redirect must be turned on in the ajax request.

Caution

If you get a CORS error while posting, set the Content-Type to text/plain.

Add

fetch("https://script.google.com/.../exec?action=add&data=Hello,World")
.then(res => res.json())
.then(res => console.log(res.status + ", id: " + res.id));

Delete

fetch("https://script.google.com/.../exec?action=delete&id=123456")
  .then(res => res.json())
  .then(res => console.log(res.status));

Read

fetch("https://script.google.com/.../exec?action=read&id=123456")
  .then(res => res.json())
  .then(res => console.log(res)); // { status: true, data: ["Hello", "World"] }

List

Lists all data if there is no limit parameter.

fetch("https://script.google.com/.../exec?action=list&limit=3")
  .then(res => res.json())
  .then(res => console.log(res)); // { status: true, data: [["Hello", "World"], [...], [...]] }

Update

fetch("https://script.google.com/.../exec?action=update&id=123456&data=Hi,World")
  .then(res => res.json())
  .then(res => console.log(res));