【发布时间】:2017-06-23 22:19:03
【问题描述】:
我正在构建一个允许用户在投注池中投注的应用程序。当用户点击一个按钮时,控制器中的一个功能被执行,但没有发出请求并返回 404 错误,任何建议将不胜感激。
function placeBet(bet) {
console.log('in place bet');
$http.post('https://colossusdevtest.herokuapp.com/api/tickets.json', {
'id': 550900,
'status': 'PLACED',
'customer_payout': '0.0',
'stake': bet,
'currency': 'GBP',
'lines': 24,
'amount_owned_customer': '1.0',
'cost': '12.0',
'created_at': '2015-07-23T17:00:10.000Z',
'offer_amount': '0.0',
'customer_winnings': '0.0',
'offers_accepted': '0.0',
'merchant_ref': '15ac9a2e-d4a8-4652-a60c-2b57d1afd92b',
'pool': {
'id': 171,
'name': 'Mixed 4',
'type_code': 'POINT_MARGIN',
'headline_prize': '4996.06',
'status': 'OPEN',
'sched_start': '2015-07-28T11:00:00.000Z',
'sched_next': '2015-07-28T11:00:00.000Z',
'currency': 'GBP',
'leg_num': 4,
'sport_code': 'RUGBY',
'has_offers': false
}
}).then(() => {
console.log('information posted');
});
}
$scope.placeBet = placeBet;
【问题讨论】:
-
您确定可以进行 POST 吗? GET 工作正常
-
您是否在提出 CORS 请求?如果是,您的 Heroku 应用是否设置为允许 CORS 请求?
标签: javascript angularjs http post http-status-code-404