Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

163
Vistas
Unexpected identifier 'getProject'. Expected ';' after async variable declaration

I have the following JS on a web page.

<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/vue@2.6.14/dist/vue.esm.browser.js'

let projectData = await getProject(projectCode);

...

</script>

The data is then stored in Vue.js to render a page. For further context the above references the following code in a seperate 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;
}

Everything works fine, except on iPhones, where I get the following error which breaks my code and prevents Vue.js from rendering the page:

SyntaxError: Unexpected identifier 'getProject'. Expected ';' after variable declaration.

I have tried wrapping it in an async function like this, but still had no luck:

(async function () {
    let projectData = await getProject(projectCode);
}())

Which returns a Vue.js related error:

Error in data(): "ReferenceError: projectData is not defined"

I'm not sure what needs to be changed for this to work correctly on iPhones (works fine in desktop Safari)

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Your attempted solution is correct, the only issue is that the let is scoped to the IIFE scope.

Re-write your code as follows:

getProject(projectCode).then(projectData => {
 // All code goes here
});

The issue original is caused by a lack of top-level await support.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda