Skip to content

Commit

Permalink
experimental tagging to test PUT method
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchelljkotler committed Jun 24, 2024
1 parent e990f74 commit 244a796
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
20 changes: 20 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
5 changes: 5 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@
<div class="button">
<button id="update">Update</button>
</div>
<div class="button">
<input id="tag_id" placeholder="id">
<button id="tag">Tag</button>
<p id="tag_txt"></p>
</div>
</div>

</div>
Expand Down

0 comments on commit 244a796

Please sign in to comment.