save()
ngResource $resource
到邮件程序API可在此处演示:
http://plnkr.co/edit/EakLFygH0QGr5zJ9xqZr
消息发送,但我在控制台日志中收到错误:
destination.push is not a function
导致此错误的原因是什么?
错误是否阻止了响应,或者我使用save()
响应回调错误了?
答案 0 :(得分:5)
$resource
不适合您的使用案例。在Angular doc中,它表示$resource
是
一个工厂,它创建一个资源对象,使您可以与REST服务器端数据源进行交互。
但是,在你的情况下,你需要的只是一个POST http调用。因此,您可以执行以下操作:
,而不是使用$resource
$http.post('https://mandrillapp.com/api/1.0/messages/send.json', post).
success(function(response) {
console.log(response);
}).
error(function() {
...
});
我已经分叉并更新了 plunk ,它没有任何错误。
来自documentation的信息:
Mandrill API主要是RESTful API。已知的警告:
所有API调用都应使用 HTTP POST 。