20:56 error Parsing error: Unexpected token =>
I've been trying to deploy the react app I made it says Parsing error: Unexpected token => this error below... I use npm
Here's my index.js (Functions)
const functions = require("firebase-functions");
const express = require("express");
const cors = require("cors");
const stripe = require("stripe")("Here comes my API Key from stripe");
// API
// - App config
const app = express();
// - Middlewares
app.use(cors({ origin: true }));
app.use(express.json());
// - API routes
app.get("/", (request, response) => response.status(200).send("hello world"));
app.post("/payments/create", async (request, response) => { const total = request.query.total;
console.log("Payment Request Recieved BOOM!!! for this amount >>> ", total);
const paymentIntent = await stripe.paymentIntents.create({
amount: total, // subunits of the currency
currency: "inr",
});
// OK - Created
response.status(201).send({
clientSecret: paymentIntent.client_secret,
});
});
// - Listen command
exports.api = functions.https.onRequest(app);
// Example endpoint
// http://localhost:5001/challenge-4b2b2/us-central1/api
I tried reinstalling react, firebase that didn't work. So started with a new project and tried again and here's the same error.
Here's my eslint config (./functions/eslintrc.js)
module.exports = {
root: true,
env: {
es6: true,
node: true,
},
extends: [
"eslint:recommended",
"google",
],
rules: {
quotes: ["error", "double"],
},
};
Edit: It works perfectly on local host and this is the only error I encountered while deploying.(cmd: firebase deploy)