From 244a796787a2e3462df036b6b522bb036f6054c6 Mon Sep 17 00:00:00 2001 From: Mitchell Kotler Date: Mon, 24 Jun 2024 15:48:48 -0400 Subject: [PATCH] experimental tagging to test PUT method --- app.js | 20 ++++++++++++++++++++ index.html | 5 +++++ 2 files changed, 25 insertions(+) diff --git a/app.js b/app.js index c991088..204f7e1 100644 --- a/app.js +++ b/app.js @@ -184,7 +184,27 @@ function update() { getDocuments(dataUrl, attrs, metadata, group, notes); } +function tag() { + var id = document.getElementById("tag_id").value; + const url = `https://api.www.documentcloud.org/api/documents/${id}/date/test_key/`; + fetch(url, { + method: "PUT", + credentials: "include", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify({"values": ["test_value"]}) + }).then((response) => { + if (response.ok) { + document.getElementById("tag_txt").innerHTML = "it worked"; + } else { + document.getElementById("tag_txt").innerHTML = "something went wrong"; + } + }).catch((err) => document.getElementById("auth").innerHTML = "something went wrong"); +} + document.getElementById("update").addEventListener("click", update); +document.getElementById("tag").addEventListener("click", tag); loadHash(); getUserId(); diff --git a/index.html b/index.html index 087f886..e9205a2 100644 --- a/index.html +++ b/index.html @@ -75,6 +75,11 @@
+
+ + +

+