Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to $decode an array of strings #362

Open
waleedasif322 opened this issue Dec 23, 2015 · 5 comments
Open

How to $decode an array of strings #362

waleedasif322 opened this issue Dec 23, 2015 · 5 comments

Comments

@waleedasif322
Copy link

First off, I'd like to thank the creators and contributors for this fantastic plugin, I've been using it for a while and it's really robust!

After I call $collection().$fetch() on a model, my server returns an array of strings. I know how to add a mixin to the model to accept an object instead of an array, as I've done before. The problem I'm having now is restmod expects objects inside the array. How do I configure this?

angular.module('app.models')
  .factory('AppointmentSlot', function(restmod) {
    return restmod.model('/appointment_slots').mix({
        // Don't know how to serialize an array of strings like: ["2015-12-04T15:00:00.000Z", "2015-12-04T15:30:00.000Z"]
    });
  });

Record $decode expected an object is the error I get.

Thanks!

@dacre-denny
Copy link

I'm having a similar issue, did you find a solution to this in the end?

@dacre-denny
Copy link

@waleedasif322 perhaps this will help? #224

@waleedasif322
Copy link
Author

Hey, I didn't figure it out yet, but if I do, will post back here. Right now I'm just using angular's $http in place of restmod for this particular API

@dacre-denny
Copy link

Thanks for that :-)

@utf4
Copy link

utf4 commented Nov 3, 2016

You can define your own Model.unpack function to re-formate the response coming straight from the server. If you are still in need of the code, I can post it out here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants