laravel - 如何从请求 Laravel 中获取 JSON?
问题描述
我使用这种方法:
public function store(CreateEvent $request)
{
dd($request->json()->all());
}
我的要求是:
{"name":"etegjgjghjghj","date":"2019-03-08"}
标题:
Accept: application/json, text/plain, */*
Content-Type: application/json
Origin: http://localhost:4200
作为响应,我在 Chrome 网络中得到空白页面,没有响应数据。
我试过这个:
public function store(CreateEvent $request){ dd('test'); }
解决方案
尝试这个:
public function store(CreateEvent $request)
{
return response()->json($request->all());
}
推荐阅读
- javascript - Asp.net signalR onclose 仅被调用一次
- mysql - 如何编写用于从用户收藏列表中删除产品项目的 sql 查询
- python - 如何用分类神经网络训练不好的奖励?
- python - 如何将 Pandas 数据框转换为具有列表中值的字典
- python - 如何从 discord.py 的错误中获取参数?
- javascript - 为什么输入捕获时未定义?
- php - PHP - 将 MySQL 查询从 mysql_query 更改为 PDO 的问题
- flutter - 如何在 Flutter(日历)中制作可滚动的月份列表?
- sql - 我应该使用什么字符串函数组合来在 impala 中做到这一点?
- r - 错误:动画对象未指定 save_animation 方法