简体   繁体   English

"“解析错误:意外的令牌 => eslint”"

[英]"Parsing error: Unexpected token => eslint"

I am seeing this error in my index.js file in VSC which looks to be caused by the app.post request.我在 VSC 中的 index.js 文件中看到此错误,这似乎是由 app.post 请求引起的。

I've attempted different parsing options in regards to eslint and emca but still aren't getting anywhere.我已经尝试了关于 eslint 和 emca 的不同解析选项,但仍然没有得到任何结果。

Appreciate any input.感谢任何输入。

Parsing error: Unexpected token => eslint<\/strong>解析错误:意外的令牌 => eslint<\/strong>

index.js index.js

const functions = require("firebase-functions");
const express = require("express");
const cors = require("cors");
const stripe = require("stripe")("hidden");

// Setting Up the 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 for this amount >>> ", total);

  const paymentIntent = await stripe.paymentIntents.create({
    amount: total, // subunits of the currency
    currency: "usd",
  });

  // OK - Created
  response.status(201).send({
    clientSecret: paymentIntent.client_secret,
  });
});


// - Listen command
exports.api = functions.https.onRequest(app);

好像您缺少parser: @babel/eslint-parser

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM