作为发送有效载荷的JSON不会形成数据Restangular发布数据 [英] Restangular post data sent as json payload not form data

查看:116
本文介绍了作为发送有效载荷的JSON不会形成数据Restangular发布数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图张贴到汽车记录的例子

I am trying to post to a car record example

Restangular.one('cars', 5).post('bids', {data: 'Some data'}).then(function() {
    $state.go('^');
});

Restangular.one('cars', 5).all('bids').post({data: 'Some data'}).then(function() {
    $state.go('^');
});

由于某些原因, {数据:一些数据'} 正在发送一个JSON有效载荷,而不是POST形式参数。我在做什么错了?

For some reason the {data: 'Some data'} is being sent as a JSON payload instead of POST form parameters. What am I doing wrong?

推荐答案

那么,如果你使用的是PHP那么你可以得到完整JSON有效载荷是这样的:

Well if you are using PHP then you can get full json payload like this:

$data = (array) json_decode(file_get_contents('php://input'));

这$数据将包含所有你通过HTTP POST发送POST数据。

this $data will contain all the post data you sent through http post.

这篇关于作为发送有效载荷的JSON不会形成数据Restangular发布数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆