简体   繁体   中英

TypeError: Cannot read properties of undefined (reading '0') from json.results

提示:本站收集StackOverFlow近2千万问答,支持中英文搜索,鼠标放在语句上弹窗显示对应的参考中文或英文, 本站还提供   中文简体   中文繁体   中英对照 版本,有任何建议请联系yoyou2525@163.com。

Error: TypeError: Cannot read properties of undefined (reading '0') at Object.handler (C:\Windows\System32\CC-Md\plugins\charainfo.js:7:70) at processTicksAndRejections (node:internal/process/task_queues:96:5) at async Object.handler (C:\Windows\System32\CC-Md\handler.js:515:25)

code:

let fetch = require('node-fetch')
let handler = async(m, { conn, text }) => {
  if (!text) throw `Masukkan query!`
  let res = await fetch(global.API('https://api.jikan.moe', '/v4/characters', { q: text }))
  if (!res.ok) throw await res.text()
  let json = await res.json()
  let { name, nicknames, url, image_url, about, type } = json.results[0]
let charaingfo = `💬 *Name:* ${name}
💭 *Nickname:* ${nicknames}
🔗 *Link*: ${url}
👤 *About*: ${about}`

  conn.sendFile(m.chat, image_url, '', charaingfo, m)
}
handler.help = ['character <nama>']
handler.tags = ['internet']
handler.command = /^(chara|character)$/i

module.exports = handler

how to fix it, thanks

No answers.You can refer to the related questions on the right.
暂无
暂无

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2022 STACKOOM.COM