Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

184
Views
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 answers
Answer question

0

In package.json,

change this

    "lint": "eslint .",

to this

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

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!