I am new at tauri and I have faced the issue with getting data from @tauri-apps/api.
"@tauri-apps/api": "^1.1.0",
"@tauri-apps/cli": "^1.1.1"
This is my React code below:
/index.jsx
import {getTauriVersion} from "@tauri-apps/api/app"
function App() {
const func = async () => {
const res = await getTauriVersion()
return res
}
return (<></>)
}
This is my tauri.conf.json
{
"build": {
"beforeDevCommand": "npm run dev",
"beforeBuildCommand": "npm run build",
"devPath": "http://localhost:1420",
"distDir": "../dist",
"withGlobalTauri": true
},
...
"tauri": {
"allowList": {"all": true}
}
}
And the error is:
Uncaught (in promise) TypeError: window.__TAURI_IPC__ is not a function
unhandledRejection: ReferenceError: window is not defined
at o (file:///C:/test/test/node_modules/@tauri-apps/api/tauri-
a4b3335a.js:1:100)
The typical 2 sources for this kind of error are: