【发布时间】:2021-10-01 23:56:25
【问题描述】:
我尝试使用 Laravel 8 和 axios 在我的 MySQL 数据库中一次插入多行,但我收到此错误
这是我的 axios 调用
async insertar(history_records) {
try {
console.log(history_records)
const response = await axios
.post("/home/insert", history_records.results)
.then(response => {
console.log("worked")
// this.categories.push(this.categoryToAdd);
})
.catch(error => {
console.log(error);
});
} catch (error) {
this.request_status = error;
console.log(error);
}
},
这里是存储功能[![在此处输入图片描述][7]][7]
PD:很抱歉使用图像而不是代码,但我遇到了一些格式问题
public function store(Request $request)
{
error_log($request);
//Create item
foreach ($request as $history_record) {
$history = new Auroracoin();
$history->history_date = $history_record->date;
$history->rate = $history_record->rate;
}
$history->save();
return $history;
}
【问题讨论】:
-
Sorry for using images instead of code, but im having some formating problems...然后修复格式问题。根据How to Ask,代码图像无用且不受欢迎。如果您需要有关如何显示代码的帮助,请参阅stackoverflow.com/help/formatting。谢谢。
标签: php mysql laravel axios laravel-8