从Restangular POST获取响应 [英] Getting Response from Restangular POST

查看:552
本文介绍了从Restangular POST获取响应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何获得响应对象后,我送Restangular POST?

How do I get the response object after I send a Restangular POST?

 firstAccount.post("Buildings", myBuilding).then(function() {
   console.log("Object saved OK");
 }, function() {
  console.log("There was an error saving");
 });

我试图获得新的对象ID。

I'm trying to get the new object id.

感谢。

推荐答案

我Restangular的创造者。弗利姆是正确的。)

I'm the creator of Restangular. Flim is right :).

在诺言,那么你从服务器返回的对象:)

In the promise then you get the object returned from the server :)

firstAccount.post("Buildings", myBuilding).then(function(addedBuilding) {
   console.log("id", addedBuilding.id);
 }, function() {
  console.log("There was an error saving");
 });

谢谢!

这篇关于从Restangular POST获取响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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