fetch fix

This commit is contained in:
Kuba 2023-02-05 19:40:55 +01:00
parent 7a5fae6dec
commit 79a3ab85da

View File

@ -2,6 +2,7 @@
<head> <head>
<script> <script>
async function parse(){ async function parse(){
document.getElementById("result").innerHTML = "Dodawanie pliku..." document.getElementById("result").innerHTML = "Dodawanie pliku..."
var data = new FormData() var data = new FormData()
data.append('file', document.getElementById("docpicker").files[0]) data.append('file', document.getElementById("docpicker").files[0])
@ -11,15 +12,16 @@
document.getElementById("result").innerHTML = "Info" document.getElementById("result").innerHTML = "Info"
data = await resp.json() data = await resp.json()
resp_db = await fetch('https://gp1q182wu2.execute-api.us-east-1.amazonaws.com/read', {method: "GET", body: data_db}) resp_db = await fetch('https://gp1q182wu2.execute-api.us-east-1.amazonaws.com/read', {method: "GET", body: ""})
var result = JSON.stringify(data_db) var result = JSON.stringify(resp_db)
document.getElementById("result").innerHTML = result document.getElementById("result").innerHTML = result
} }
</script> </script>
<title>Chmura</title> <title>Invoice parser</title>
</head> </head>
<body> <body>
<input type="file" id="docpicker" accept=".pdf" onchange="parse()" /> <input type="file" id="docpicker" accept=".pdf" onchange="parse()" />
<p id="result"></p> <p id="result">...</p>
<p id="test">...</p>
</body> </body>
</html> </html>