0

I am writing a function that accepts input from an API endpoint. But the problem is when I now want to insert the records into the database. Immediately I add the async before the function I get an eslint error of Parsing Error: Unexpected token =>. Because of this, I cannot deploy the function. Kindly also look at the attached screenshot

app.post("/c2b/confirm", async (req, res) => {
  console.log("----------confirm-------------");
  console.log(JSON.stringify(req.body));
  const payment = admin.firestore().collection("payments").doc();
  await payment.set(req.body);
  res.status(200).json({"ResultCode": 0, "ResultDesc": "Success"});
});

exports.main = functions.https.onRequest(app);

enter image description here

1 Answer 1

2

It is a linter error. Please, be sure you have these in your eslintrc:

{
  "env": {
    "node": true,
    "es6": true
  },

  "parserOptions": {
    "ecmaVersion": 8
  }
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.