Php laravel中的Angular js post请求返回null
这是我的请求Php laravel中的Angular js post请求返回null,php,angularjs,laravel,laravel-5,Php,Angularjs,Laravel,Laravel 5,这是我的请求 route.service('MetaDataService',function ($http) { $http.defaults.headers.post["Content-Type"] = "application/x-www-form-urlencoded"; this.newItem = function (url,data) { console.log(data); return $http.post('/
route.service('MetaDataService',function ($http) {
$http.defaults.headers.post["Content-Type"] = "application/x-www-form-urlencoded";
this.newItem = function (url,data) {
console.log(data);
return $http.post('/'+url,data).then(function (response) {
return response.data.status;
});
}
});
拉威尔控制器
dd$request->all returns[]数组
我还记录了请求控制台之前的数据。logdatait将给出ouptut
请求头
尝试以
dd($request->json()->all());
您使用的请求是否正确
use Illuminate\Http\Request;
实际上,angular js作为原始数据发送,可通过以下方式检索:
file_get_contents("php://input");
在Laravel中,有一种首选或推荐的方式:
$request = Request::instance();
$content = $request->getContent();
或
快乐编码 您能给我们看一个示例数据吗?[name:hello]控制台的输出。logdata@Demonyowh你知道吗?你在控制台中是否遇到了诸如访问控制允许源代码之类的错误?不,没有CORS issuesTried,但返回空的arrayCheck天气文件\u get\u contents'php://input“给了你一些东西。或者您可以使用$request->namehmmm。。。等待同样的结果。
file_get_contents("php://input");
$request = Request::instance();
$content = $request->getContent();
$content = Request::getContent();