我試圖設(shè)置兩個(gè)變量“ TOTAL_GHE_ISSUES”“ GHE_ISSUE_NUMBERS”,然后將它們插入到https://slack.dev/node-slack-sdk/webhook之后的松弛Webhook的json有效負(fù)載中。我對(duì)js / nodejs完全沒(méi)有經(jīng)驗(yàn),所以請(qǐng)理解我是否犯了一個(gè)簡(jiǎn)單的錯(cuò)誤我嘗試在.js腳本頂部設(shè)置變量,并嘗試轉(zhuǎn)義/取消轉(zhuǎn)義值,但是遇到了麻煩const IncomingWebhook = require('@slack/webhook').IncomingWebhook;const url = process.env.SLACK_WEBHOOK_URL;const webhook = new IncomingWebhook(url);var x = "10"const TOTAL_GHE_ISSUES = "10"const GHE_ISSUE_NUMBERS = "90"// Send the notificationif (x == "10")(async () => { await webhook.send({ text: "*Daily Overdue Nessus Vulnerability Alert*", attachments: [{color: "#FF0000", blocks: [{type: "section",text: {type: "mrkdwn",text: "@here *TOTAL_GHE_ISSUES* Overdue Nessus Vulnerability issues reported \nOverdue Nessus Vulnerability GHE Issue Numbers: *GHE_ISSUE_NUMBERS*"}}]}] });})();else {console.log("What's up");}我希望webhook返回TOTAL_GHE_ISSUES和GHE_ISSUE_NUMBERS的10和90,但它返回的是文字字符串編輯:我使用了下面發(fā)布的字符串連接,它達(dá)到了我的目的,并使我的有效負(fù)載更加模塊化,非常感謝您的所有幫助text: "@here *" + TOTAL_GHE_ISSUES + "* Overdue Nessus Vulnerability issues reported \nOverdue Nessus Vulnerability GHE Issue Numbers: *" + GHE_ISSUE_NUMBERS + "*"
有沒(méi)有一種方法可以將js變量插入JSON有效負(fù)載?
慕容3067478
2021-04-05 12:14:30