I have a simple vue vite ts app. I'm trying to replace the localstorage with a local database. So I found this sql.js library. I installed sql.js and @types/sql.js for typescript. I tried to connect to my db.sqlite file. But when I did so I got a bunch of errors in the console.
That's how I connect to the db.sqlite code:
import initSqlJs from "sql.js"
initSqlJs({
locateFile: () => "./db.sqlite",
}).then(SQL => {
const db = new SQL.Database()
console.log(db)
})
And that's the errors:
wasm streaming compile failed: TypeError: Failed to execute 'compile' on 'WebAssembly': Incorrect response MIME type. Expected 'application/wasm'.
falling back to ArrayBuffer instantiation
failed to asynchronously prepare wasm: CompileError: WebAssembly.instantiate(): expected magic word 00 61 73 6d, found 0a 2f 2f 20 @+0
Aborted(CompileError: WebAssembly.instantiate(): expected magic word 00 61 73 6d, found 0a 2f 2f 20 @+0)
Uncaught (in promise) Error: CompileError: WebAssembly.instantiate(): expected magic word 00 61 73 6d, found 0a 2f 2f 20 @+0
Uncaught (in promise) RuntimeError: Aborted(CompileError: WebAssembly.instantiate(): expected magic word 00 61 73 6d, found 0a 2f 2f 20 @+0). Build with -sASSERTIONS for more info.
What am I doing wrong? How can I connect to my db.sqlite file?