语法错误 - 带节点的意外标识符XMPP
我是Node和XMPP的新手,我在使用ltx读取聊天节时遇到错误,错误是:。
const Client = require('node-xmpp-client')
, ltx = Client.ltx
const options = {
jid: 'bot@localhost',
password: 'tellnoone'
}
const client = new Client(options)
client.on('online', (connectionDetails) => {
console.log('We are connected!')
console.log(connectionDetails)
sendPresence()
})
const sendPresence = () => {
var stanza = new ltx.Element('presence')
console.log('Sending presence: ' + stanza.toString())
client.send(stanza)
}
client.on('stanza', (stanza) => {
if (false === stanza.is('message')) return /* Not a <message/> stanza */
const messageContent = stanza.getChildText('body')
if (!messageContent) return /* Not a chat message */
const from = stanza.attr('from')
const logEntry = 'Received message from ' ${from} ' with
content:\n${messageContent}'
console.log(logEntry)
})
文件名是:index.js
以下是代码:
.row
答案 0 :(得分:0)
尝试更改行
const logEntry = 'Received message from ' ${from} ' with
content:\n${messageContent}'
到
const logEntry = `Received message from ${from} with content:\n ${messageContent}`
模板字符串使用反引号代替引号。