-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.html
51 lines (47 loc) · 1.77 KB
/
test.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<!DOCTYPE html>
<html>
<head>
<title>Trigger AWS Lambda</title>
<script>
function triggerLambda() {
const url = 'https://m83in5olml.execute-api.ap-southeast-2.amazonaws.com/default/GetSetNumber';
const documentId = "13LwidOuE1Y1MFaZ7uwVlh9zfMuf3RfxUoFGuCg6j_fI";
const textInput = document.getElementById("textToAppend");
const data = {
text: textInput.value,
document_id: documentId,
};
fetch(url, {
method: 'POST',
body: JSON.stringify(data),
headers: {
'Content-Type': 'application/json'
}
}).then(response => response.json())
.then(data => console.log(data))
.catch((error) => {
console.error('Error:', error);
});
}
function fetchDocumentContent() {
const url = `https://m83in5olml.execute-api.ap-southeast-2.amazonaws.com/default/GetSetNumber?document_id=13LwidOuE1Y1MFaZ7uwVlh9zfMuf3RfxUoFGuCg6j_fI`;
fetch(url, {
method: 'GET'
}).then(response => response.json())
.then(data => {
const contentDiv = document.getElementById("documentContent");
contentDiv.textContent = data.content; // Display the content in the div
})
.catch((error) => {
console.error('Error:', error);
});
}
</script>
</head>
<body>
<textarea id="textToAppend" placeholder="Type text to append to the document..."></textarea>
<button onclick="triggerLambda()">Send Typed Text to Lambda</button>
<button onclick="fetchDocumentContent()">Fetch Document Content</button>
<div id="documentContent" style="margin-top: 20px; border: 1px solid #ccc; padding: 10px;"></div>
</body>
</html>