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

191
Vistas
Firebase Functions, Parsing error: Unexpected token =>

I'm building my first firebase function with Js to handle card payments with Checkout.com API, I've installed both checkout and firebase JavaScript SDK's and this is my index.js folder:

const functions = require("firebase-functions");
const { Checkout } = require("checkout-sdk-node");
const cko = new Checkout("sk_test_XXXXX-XXXX-XXXX");

exports.payWithToken = functions.https.onCall(async (data, context) => {
    try {
        const payment = await cko.payments.request({
            source: {
                token: data.token,
            },
            customer: {
                email: context.auth.token.email
            },
            currency: data.currency,
            amount: data.amount,
        })
        return {
            "Status": payment.status,
            "3DS-Link": payment.redirectLink,
            "Approved": approved,
            "Flagged": risk.flagged,
        };
    } catch (error) {
        console.log(error)
        throw new functions.https.HttpsError(error.name, error.message, error);
    }
});

I think I followed the documentation correctly but for some reason, I couldn't deploy this function to firebase and I get this error:

Parsing error: Unexpected token =>

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

0

In package.json,

change this

    "lint": "eslint .",

to this

    "lint": "eslint",
about 4 years ago · Juan Pablo Isaza Denunciar

0

I found the solution on this page.

Essentially

Arrow functions are an ES6 feature, but here you have an async arrow function.

Async functions in general are an ES8 (or 2017) feature. Therefore you need to specify the following setting at the root of your config: parserOptions: { ecmaVersion: 8 // or 2017 }

So I needed to update my .eslintrc.js file to this

module.exports = {
  root: true,
  env: {
    es6: true,
    node: true
  },
  parserOptions: {
    ecmaVersion: 8
  },
  extends: ['eslint:recommended', 'google'],
  rules: {
    'comma-dangle': 'off',
    'quote-props': 'off',
    indent: ['error', 2]
  }
};
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