bsmsapp/terraform/organization/html/index.html

50 lines
1.4 KiB
HTML

<!DOCTYPE html>
<meta charset="UTF-8">
<html>
<head>
<title>BSMSapp</title>
<div align="center">
</head>
<br><br>
<body bgcolor="#FFFFFF" text="Black">
<h1><span id="replace">BSMSapp</span></h1>
<form id="myForm">
<input value="0" name="id"/>
<br>
<input value="0" name="stock"/>
<br><br>
<input type="submit" value="Upload"/>
</form>
</body>
</div>
</html>
<script>
const thisForm = document.getElementById('myForm');
thisForm.addEventListener('submit', async function (e) {
e.preventDefault();
// console.log(thisForm)
// console.log(new FormData(thisForm).entries())
const formData = new FormData(thisForm).entries()
const str = JSON.stringify(Object.fromEntries(formData))
console.log(str.replace(/\"/g, ''))
let test = {
id: 212311111,
stock: 131211
}
const response = await fetch("${ENDPOINT}/resource", {
method: 'POST',
// mode: 'cors',
headers: {
'Content-Type': 'application/json'
},
// body: str.replace(/\"/g, '')
body: JSON.stringify(test)
});
const result = await response.json();
console.log(result)
});
</script>