When using this JavaScript on a webpage, I encounter an issue:
<script async type="module">
import {projectCode} from "./assets/js/config.js";
import {getProject} from "./assets/js/saleproject.js";
import {getAccount} from "./assets/js/account.js";
import Vue from 'https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="5e282b3b1e6c7068706f6a">[email protected]</a>/dist/vue.esm.browser.js'
let projectData = await getProject(projectCode);
...
</script>
To render a page in Vue.js, the data fetched is stored. The code referred to above is found in a separate file:
import { server } from './config.js';
export async function getProject(projectCode) {
const response = await fetch(server + '/saleproject/GetByCode/' + projectCode);
const projectData = await response.json();
return projectData;
}
While everything functions correctly on desktops, iPhones present an error that interrupts Vue.js rendering:
SyntaxError: Unexpected identifier 'getProject'. Expected ';' after variable declaration.
An attempt was made to resolve it by enclosing it in an asynchronous function, but still encountered difficulties:
(async function () {
let projectData = await getProject(projectCode);
}())
This resulted in a Vue.js error:
Error in data(): "ReferenceError: projectData is not defined"
Adjustments are needed to ensure proper functioning on iPhones (currently works on desktop Safari).