javascript - 回复消息时无法在消息中添加图像
问题描述
我正在尝试将图像附加到作为重播的消息上。
msg.reply(JSON.parse(data).results[0].overview, { file : JSON.parse(data).results[0].poster_path});
但仅发送作为字符串的“概述”,没有“poster_path”图像。
为什么会这样,我该如何解决?
我已经检查并且 JSON 数据是有效的。
解决方案
为了使您的代码更清晰并避免内存过载,您可以调用一次
// get first value
var firstResult = JSON.parse(data).results[0];
// confirm the result
console.log(firstResult);
// action
msg.reply(firstResult.overview, { file : firstResult.poster_path});
尝试在控制台中查看 firstResult 以确认响应。
推荐阅读
- python - 如何在 fstrings 中使用 .loc?
- python - 如何用 null 替换 pandas 列中的特定字符?
- mysql - 具有特定选择的mysql默认排序顺序
- r - 在自定义函数中使用 ggplot stat_function "group"
- makefile - `Makefile`规则重新生成目标文件目录而不从头开始重新编译?
- django - Django DRF - 使用序列化程序 + json 更新配置文件
- sql - 使用数据透视并获取错误缺少表达式
- mongodb - 在 aws ec2 服务器上安装 MongoDB
- spring - 使用 @DBref 使用 Postman 发送 POST 请求
- azure - Azure Functions:绑定类型“eventHubTrigger”未注册