angular resource put request with array like params

120 views Asked by At

I have to recreate the following url using angular resource, but i have been trying and can't do it:

my_domain/plan_memberships/24?access_token={{access_token}}&plan_membership[archived]=1

the problem is plan_membership[archived]=1 im only getting plan_membership=archived:1 and i can't seem to find a way to do it. My resource is as follows:

.factory('deleteFromPlan', ['$resource', function ($resource){
    return $resource(
            angularConfig.rootApiEndpoint + '/me/plans/:plan_slug/plan_memberships/:membership_id',
            {//param defaults
                plan_slug: '@plan_slug',                        
                token: '@access_token',
                membership_id: '@membership_id',
                plan_membership: '@plan_membership[archived]'
            },
            {
                'update': {
                    method: 'PUT'                                                   
                }
            }
        );
}])

and im using it like this:

deleteFromPlan.update({
        access_token: $rootScope.angularConfig.user.access_token,
        plan_slug: sharedVars.getPlanId(),
        membership_id: membershipId,
        plan_membership: { archived: 1 }},
        function(data){
            console.log(data);
            spinner.hideActionLoader(overlay);  
            $scope.showOptionsModalMembers = false;  
    });

when i do this, i get this url:

http://localhost:3000/api/v1/me/plans/1/plan_memberships/10?plan_membership=%7B%22archived%22:1%7D&token=111111

when i should get this:

http://localhost:3000/api/v1/me/plans/1/plan_memberships/10?plan_membership[archived]=1&token=111111

Is there something else i need to do? also, its a PUT request

Thanks in advance!

0

There are 0 answers