I have an index.html and script . js file. I want to store the data from the form element in the index.html file but I get this error upon submitting: crbug/1173575, non-JS module files deprecated.
This is my index.html file
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Film survey</title>
<link rel="stylesheet" href="style.css" />
</head>
<body>
<form action="send" method="post" enctype="multipart/form-data">
<h1>Please fill out this short survey</h1>
<div><label for="film">What film did you watch?</label></div>
<div><input type="text" id="film" name="rating" value="" required /></div>
<div>
<label for="rating">Rate the film (1 -very bad, 5 - very good) </label>
</div>
<div>
<input
type="number"
id="rating"
name="rating"
value=""
min="1"
max="5"
required
/>
</div>
<input type="submit" onclick="sendData()" class="btn"></input>
</form>
<script src="script.js"></script>
</body>
</html>
and this is my script.js file
function sendData() {
let filmElement = document.getElementById("film");
let filmValue = filmElement.value;
console.log(filmValue);
let ratingElement = document.getElementById("rating");
let ratingValue = ratingElement.value;
console.log(ratingValue);
const url = "http://localhost:3000/index.html/send";
const otherPara = {
headers: {
"content-type": "application/json",
},
body: data,
method: "POST",
};
fetch(url, {
// returns a promise
method: "post", // specify method as post
body: mail, // specify body as mail to send to request
})
.then((response) => response.json()) // converting promise to JSON
.then((res) => console.log(res)) // view the response from server
.catch((error) => console.log(error));
}
I tried looking for a solution here on another post, link Crbug/1173575, non-JS module files deprecated. chromewebdata/(index)꞉5305:9:5551 But nothing helps.