gpt4 book ai didi

javascript无法读取graphql查询中未定义的属性 '0'

转载 作者:行者123 更新时间:2023-11-29 15:18:26 25 4
gpt4 key购买 nike

我无法在此常量中设置值:

const targetedMessageTemplate = { 
"query": createTargetedMessage(input: {
conversationId: '',
targetUserId: '',
targetDialogId: '',
annotations: [{
genericAnnotation: {
title: '',
text: ''
}
}]
})
};

调用时:

var test= targetedMessageTemplate;

test.annotations[0].title = 'Test title';

返回:

TypeError: cannot read '0' of undefined.

设置 conversationId 变量的值工作正常,但是访问注释数组似乎是一个问题。

非常感谢任何关于我遗漏的提示。谢谢

最佳答案

genericAnnotation 对象键没有写。

test.annotations[0].genericAnnotation.title = 'Test title';

但错误是不同的。您确定 annotations 不是空数组吗?

关于javascript无法读取graphql查询中未定义的属性 '0',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46479025/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com