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

178
Vistas
"Missing semicolon" error on Async function declaration

In a Vue app, I want to group js functions in a js file. In getData.js , I have the following:

import { collection, getDocs } from 'firebase/firestore/lite';
import { db } from "./firebase/index";
import store from "../store/index"

  
  async getProjects () { 
    const querySnapshot = await getDocs(collection(db, "projects"));
      querySnapshot.forEach((doc) => {
      let project = doc.data()
      project.id = doc.id
      store.state.currentProjectList.push(project)
    });
  }



  export { getProjects } 

I get the "Missing semicolon." error on the line where I declare the function: async getProjects().

(I know this isn't the way to add data to the store but this is only for testing purpose)

Thanks for any help!

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

0

async getProjects () { is method declaration syntax; it is only allowed inside an object or class definition.

To create a local function you need to use a function declaration or an arrow function.

async function getProjects () { 

or

const getProjects = async () => {

(You could also use a function expression, but that gets even further from the syntax you had).


You also have a missing semi-colon at the of the previous line – import store from "../store/index" which isn't a JS error (but might be a linting error if you are using a linter and didn't mention that).

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