I'm trying to import script.js into my app.js and it returns an error that says "Uncaught SyntaxError: import not found: script app.js:1:9" and also breaks getSelectedItems function and says that is also undefined. I included my HTML because I'm unsure if there could be an error there.
I'm trying to import this into app.js
export class script {
//Save movies into the local storage
saveIntoStorage(item) {
const items = this.checkStorage();
items.push(item);
// Add new array into the localStorage
localStorage.setItem("items", JSON.stringify(items));
}
// return movies from storage
checkStorage() {
let items;
// Check the localStorage
if (localStorage.getItem("items") === null) {
items = [];
} else {
items = JSON.parse(localStorage.getItem("items"));
}
return items;
}
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>My Website</title>
<link rel="icon" href="./favicon.ico" type="image/x-icon">
</head>
<body>
<main>
<h1>Welcome to My Website</h1>
</main>
<script src="app.js" type="module"></script>
<script src="script.js" type="module"></script>
</body>
</html>
This is from my app.js
import {
script
} from "./script.js";
// Store the user input from dropdown menu into a new array
function getSelectedItems() {
const items = document.getElementsByClassName("selectVal");
myApp.results = [];
for (let i = 0; i < items.length; i++) {
const item = items[i];
const userInput = item.options[item.selectedIndex].value;
myApp.results.push(userInput);
}
}