在控制臺中,我不斷收到語法錯誤,Uncaught SyntaxError: Unexpected token '}'。我檢查了我的 JavaScript,看看是否有任何問題,但我對這種編碼很陌生,不知道為什么會發生這種情況?到底是JSON端的錯誤還是JS端的錯誤?謝謝。代碼在這里: const { prefix, token } = require('./config.json'); const Discord = require('discord.js'); const client = new Discord.Client(); client.once('ready', () => { console.log('Ready!'); console.log(prefix) }); client.login(token); client.on ('message', message =>{ if (message.content === '!ping') {message.channel.send('pong')} });和 json 代碼: {"prefix":"!", "token": "token_goes_here"}
當我嘗試從此 JSON 文件獲取信息時,為什么會出現語法錯誤?
翻閱古今
2023-07-29 13:50:08