Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Matt Shwery
    @mshwery
    trends may not be the best example, but the point is that the resource is a has_one relationship to the parent.
    Matt Shwery
    @mshwery
    @mgonto any recommendation on this ^
    Cesar Bretana Glez
    @bretanac93
    Hello everyone, I spend the last hour looking for some resources that help me work with restangular combined with some other stuffs, I'm newbie on this, so I need a thing or two
    anggiaj
    @anggiaj
    Hey
    Matt Shwery
    @mshwery
    @bretanac93 anything in particular you were looking for? could you elaborate on "I need a thing or two"?
    Daniel Spasojevic
    @dspasojevic
    Hi, is there a way to replay a request from an error handler that will use the full interceptor stack for any replies?
    chanzian
    @chanzian
    hi, guys may i ask is printing(print out data as voucher) possible in ng-admin? anyone can help answer?
    Fredrik Boström
    @bostrom
    Hi all! Just wondering if anyone knows whether this project is being maintained anymore? Seems to be quite a few PRs open (including one of mine), but no-one seems to consider merging them.
    Matt Erman
    @CodeLiftSleep
    Quick question...I was trying to set up Restangular to return all JSON data from this site: https://jsonplaceholder.typicode.com/posts but I couldn't get it working with Restangular.all---I tried many different configurations, using $object after the get() and without it, etc, but it kept returning empty. If I attempted to return data using Restangular.one('posts',52).get(); it worked fine and returned that piece of data. Could anyone let me know what I was doing wrong and how to get this to work?
    Fredrik Boström
    @bostrom

    @CodeLiftSleep try

    Restangular.all('posts').getList().then(function (response) {
        console.log(response);
    });

    Example here: http://codepen.io/anon/pen/wzLYoo?editors=1010

    Matt Erman
    @CodeLiftSleep
    I am using a global function to make a restangular call and return the data, but keep getting undefined...I am doing it this way so I can have error checking built in and not have to do it with every call...this call works fine: Restangular.one('Contract/Get').get().then(function (response) { $scope.gridOptions.data = response; })
    but when I do this: APICalls.Get($scope.gridOptions.data, "Contract/Get", "There was an error retrieving the contracts!") where args are (model, route, errorMsg), $scope.gridOptions.data is undefined. I believe it has to do with setting a deferred promise because its an Async operation, but when I set the promise, resolve it and then return it, it doesn't come back as undefined, but it doesn't come back as anything and the code never seems to run APICalls.Get($scope.gridOptions.data, "Contract/Get", "There was an error retrieving the contracts!").then(function (response) { $scope.gridOptions.data = response;}) any help here?
    Matt Erman
    @CodeLiftSleep
                  this.GetTest = function (model, route, errorMsg) {
                            var deferred = $q.defer();
                            Restangular.one(route).get().then(function (response) {
                                model = response;
                                deferred.resolve();
                            }), function (e) {
                                alertify.error("There was an error retrieving the contracts!"); //Message passed in when it errors
                                console.log('Error!! ' + e.name + ':  ' + e.message); //console logs name of error and message
                                deferred.reject();
                            };
                            deferred.promise;
                        };
    why is this not waiting for deferred to return?? It never runs the .then(function (response)) until after the code in the main program continues
    I'm calling this from a service
    Fredrik Boström
    @bostrom
    Restangular's async methods return promises themselves, so there's no need to create your own deferred objects. Just return whatever Restangular returns. Your code modified:
    this.GetTest = function(model, route, errorMsg) {
      // restangular returns a promise, pass that on directly
      return Restangular.one(route).get().then(function(response) {
        model = response;
        return response; // if you want to pass the response on to whoever called GetTest
      }),
      function(e) {
        alertify.error("There was an error retrieving the contracts!"); //Message passed in when it errors
        console.log('Error!! ' + e.name + ':  ' + e.message); //console logs name of error and message
      };
    };
    Matt Erman
    @CodeLiftSleep
    Thanks! I see what is going on now, but it was confusing at first...
    Matt Erman
    @CodeLiftSleep
    Is there any reason why on a Delete or Update Restangular would be adding in extra URL parts?
    For instance I have several forms, on most of them Update and Delete work for me when I restangularizeElement and pass in "Contract/Update?id=" for the route but on one of them it ends up "Contract/Contract/Update?id=" so I just pass in "Update?id=" and it works fine, but on one of the Delete's its now attempting to go to ...."API/API/Contract/Delete?id=" instead of "API/Contract/Delete?id="...the part that is weird is I am not passing in the extra API from anywhere, and the only other place a URL is set is in the main setBaseUrl when angular loads...where is this extra API coming from??
    Fredrik Boström
    @bostrom
    @CodeLiftSleep can you show some real code to debug?
    Matt Erman
    @CodeLiftSleep
    @bostrom I endde up getting it sorted out...it was a dumb mistake on my part
    Fredrik Boström
    @bostrom

    @CodeLiftSleep it would be much easier to help you if we could see some real code of what you're actually doing.

    Restangular works well with API calls like GET /books, PUT /books/15, DELETE /authors/50/books/5 and so on. If you have some more exotic backend API, then you most probably have to either do custom requests in Restangular (customGET, customPOST etc), or use vanilla $http service in angular.

    Please put up a code example on jsfiddle or codepen or github etc so we can understand what you're trying to accomplish.

    Matt Erman
    @CodeLiftSleep
    is the associated call being made in APICalls
    Fredrik Boström
    @bostrom
    Where's Restangular in this?
    Matt Erman
    @CodeLiftSleep
    once the page redirects after you successfully finish the update, the route then becomes "Module/Module/Update?id=" if you try and update anything else
    Lol...ack! just realized I'm not using it for this, OMG I feel like an idiot
    hahahaha
    Ok, back to the issue at hand...do you know of a way to resolve that?
    Fredrik Boström
    @bostrom

    @CodeLiftSleep I don't think this is the proper forum for random JS questions, you should probably try StackOverflow or similar instead.

    However, I created a pen of your code and it runs ok, so your problem must be elsewhere. http://codepen.io/anon/pen/jVNyJX?editors=0011#0

    Matt Erman
    @CodeLiftSleep
    I think I fixed it..."../Module/Update?id=" seems to work right
    but its weird because the same thing doesn't work with delete, nor does delete have the same issue
    although it isn't redirecting you so I guess maybe that is why
    Fredrik Boström
    @bostrom
    You probably shouldn't be using window.location.href directly either. Try using ng-router or ui-router.
    Matt Erman
    @CodeLiftSleep
    we aren't using Angular routes currently, we are kind of retrofitting Angular with ASP.net/MVC
    That is probably going to switch over but it hasn't happened yet
    Matt Erman
    @CodeLiftSleep
    Ok, now this is a restangular question...how would I access A relative path as a get? Like in Razor I could do $http.get('@Url.Content("~/Utility/GetAllProviders")' to call a relative path to a function that will retrieve data
    archas
    @archasek
    hello guys!
    would be great if anybody can take a look at mgonto/restangular#1435
    thanks :)
    Matt Erman
    @CodeLiftSleep
    How do you utilize @Url.Content to call a service function in restangular to get data?
    Colton Colcleasure
    @colshacol
    I have been working for hours to resolve this darn getList SHOULD be an array... error, and I just can not beat it. Can anybody offer assistance?
    Fredrik Boström
    @bostrom
    @colshacol still having problems? That message usually appears when a "list" endpoint doesn't return an array as topmost object. I.e. your list is wrapped in another object. Or perhaps you have a responseInterceptor that alters the data in some way before passing it to Restangular.
    Colton Colcleasure
    @colshacol
    @bostrom I spent 3 hours trying to solve it and finally c/p 4 lines of code that solved it. -_- Angular is not my forte, but work insisted.
    Matt Erman
    @CodeLiftSleep
    Anyone here? I'm trrying to use a restangular setErrorInterceptor but its not giving me anything in the content section I am sending over in the HTTPResponseMessage
    return new HttpResponseMessage(System.Net.HttpStatusCode.NotModified) { Content = new StringContent(ex.InnerException.ToString()) };
     RestangularProvider.setErrorInterceptor(function (response, deferred, responseHandler) {
                            alertify.error("Error! " + response.statusText + " : " + response.status);
                            return true;
    In this case it should be returning the content saying "Cannot insert duplicate row in database...blah blah blah" but that appears nowhere in any of the Restangular content...data comes back as ""
    the response doesn't contain the content from the HTTPResponse...where do I get that from?
    Matt Erman
    @CodeLiftSleep
    When an uncaught exception comes back ALL that info is available in the response...when I catch it, none of it is, WTF is the point in that??
    harishav
    @harishav
    Hi all, can I send request body in delete method?? Thanks in advance