async editSurvey(answers) {
let answer_text;
let id;
answers.map((answer, index) => {
answer_text = answer.answer_text;
id = answer.id;
});
body: JSON.stringify({
question: {
answers_attributes: {
'0': {
answer_text: answer_text,
id: id
} }
}
})
}
这是 api 代码,我想要地图功能,以便在每个地图上它都应该转到 JSON.stringify 并分配值,但在我的情况下,它将转到 JSON.stringify 以获取最后一个地图元素。所以请建议我任何解决方案。先感谢您。
async editSurvey(answers) {
let answer_text;
let id;
answers.map((answer, index) => {
answer_text = answer.answer_text;
id = answer.id;
return {
body: JSON.stringify({
question: {
answers_attributes: {
'0': {
answer_text: answer_text,
id: id
}
}
}
}
});
尝试做这样的事情,检查括号一次
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句