I am a total noob to node.js and I am trying to separate a long line of code. The es-lint says it cannot be more than 80 characters . I do not want to turn off es-lint because it helps me ensure a clean deploy to firebase. Here is the code in it's entirety
exports.refresh = functions.https.onRequest((req, resp) => { console.log(JSON.stringify(req.body)); const jsonObject = req.body; console.log("loginName"); console.log(jsonObject["event"]["loginName"]); for (let i=0; i<jsonObject["event"]["data"]["providerAccount"].length; i++) { console.log(jsonObject["event"]["data"]["providerAccount"][i]["providerId"]); } resp.status(200).end(); }); The line of code that is in question is
console.log(jsonObject["event"]["data"]["providerAccount"][i]["providerId"]); It's too long says es-lint. I have tried
console.log(jsonObject["event"]["data"]["providerAccount"], [i]["providerId"]); and
console.log(jsonObject["event"]["data"]["providerAccount"] + [i]["providerId"]); and I get errors. So how do I properly break a one line code across multiple lines? Many thanks for your help!
https://stackoverflow.com/questions/66131184/how-to-separate-a-line-of-code-in-node-js February 10, 2021 at 01:05PM
没有评论:
发表评论