我发送了这个请求,该请求是来自reactjs应用的对象数组,它是向nodejs(sequelize,mysql)后端发送的
{
"Qusetion":"new question",
"Qusetiontype":"AddedAnswers",
"Qusetionanswers":[
{
"QuestionAnswer":"a1"
},
{
"QuestionAnswer":"a2"
}
],
"Surveyid":"9fe96b40-7704-11e9-b46f-3f2c20a71682"
}
nodejs脚本
QuestionAnswer.create(req.body.Qusetionanswers.map(Answer=>{
Qusetionanswer=Answer.QuestionAnswer,
QuestionId=qid
})
).then(res=>{console.log(res)}).catch(err=>{console.log(err)})
我的问题:在尝试发送新问题时,我在邮递员中遇到了错误消息,我发现该问题不接受对象的数组,别无其他。 >
{
"message": "this.build(...).save is not a function"
}
答案 0 :(得分:1)
我会这样尝试。一个接一个地创建。还是您要归档其他内容?
$file_open = fopen("data.csv","a");
$no_rows = count(file("data.csv"));
$itemID = $no_rows+1;
$fclose($file_open);
$itemDataArray = array(
'ID' => $no_rows,
'ItemName' => $_POST['itemName'],
'ItemImage' => $_POST['itemImage'],
'ItemCapacity' => $_POST['itemCapacity'],
'ItemFuelType' => $_POST['itemFuelType'],
'ItemDescription' => $_POST['itemDescription'],
'ItemFits' => $_POST['itemFits'],
'ItemPrice' => $_POST['itemPrice'],
);
$file_open = fopen("data.csv","w");
fputcsv($file_open, $itemDataArray);
fclose($file);
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Your record was added</title>
</head>
<body>
<table width="200" border="0">
<tbody>
<tr>
<th scope="col">Detail</th>
<th scope="col">Value</th>
</tr>
<tr>
<td>Item Name</td>
<td><?php echo $_POST['itemName']; ?></td>
</tr>
....
</table>
</body>
</html>