【发布时间】:2017-12-21 12:42:38
【问题描述】:
answers.map((answer, index) => {
answer_text = answer.answer_text;
id = answer.id;
return fetch(BASE_URL + url, {
method: 'PUT',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
'Authorization': 'Token token=' + token
},
body: JSON.stringify({
question: {
answers_attributes: {
'0': {
answer_text: answer_text,
id: id
}
}
}
})
});
})
我使用了 map 函数,因此在每张地图上它都应该转到 JSON.stringify 并分配值。但我收到错误“未处理的承诺拒绝 TypeError:无法读取未定义的属性 'json'”。请建议我任何解决方案。
提前致谢。
【问题讨论】:
标签: json reactjs api react-native map-function