我正在尝试使用iron-ajax但内容类型=' application / json'不支持。
dt[, `:=`(count2012 = sum(year == 2012), count2013 = sum(year == 2013)), .(account)][]
# account year count2012 count2013
#1: treu65 2012 1 1
#2: treu65 2013 1 1
#3: treg23 2013 1 2
#4: treg23 2013 1 2
#5: treg23 2012 1 2
财产 -
<iron-ajax id="ajaxRequestOtp"
method="POST"
url="[[apiEndPoint]]/user-sms-auth"
body="{{requestOtpBody}}"
handle-as="json"
headers='{"Accept": "application/json"}'
on-response="_responseRequestOtp"
on-error="_errorResponseRequestOtp"
content-type='application/json'>
</iron-ajax>
计算功能 -
static get properties() {
return {
apiEndPoint: {
type: String,
value: 'http://example.com'
},
requestOtpBody: {
type: String,
computed: '_createRequestOtpBody(mobileNumber)',
notify: true
}
};
}
这不起作用,404 Bad request。我需要将JSON对象发送到我的服务器。
错误讯息 -
_createRequestOtpBody(mobileNumber) {
let body = {
phone_number: "+91" + mobileNumber
}
return JSON.stringify(body);
}
答案 0 :(得分:0)
制作requestOtpBody
=&gt; type: Object
,并跳过JSON.stringify
步骤。
_createRequestOtpBody(mobileNumber) {
return { phone_number: "+91" + mobileNumber };
}