question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Different endpoints for different actions; dynamic endpoints

See original GitHub issue

Hi. For example, I have User model with endpoint /users/, and Group model with endpoint /groups/. User have m2m relation with Group. Request for fetching associated groups looks like /users/:id/groups. Question: how to change Group endpoint just for particular GET request?

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
VenkatRamReddyKcommented, Sep 24, 2016

Feel free to Fork the Working Example: Plunker

Accessing // GET request:api/v1/users/4/settings/ui


(function(angular) {
  'use strict';

angular.module('xmpl', ['angular-data.DS'])
.service('User', function(DS) {
  return DS.defineResource({
    name: 'users', 
    endpoint:'api/v1/users',
    computed: {
          id:function(){return 4;}
        }
  });
})
.service('Usersettings', function(DS, User) {
  return DS.defineResource({
        name: 'settingsui',
        endpoint:'settings/ui',
        computed: {
          id:function(){return 4;}
        },
        relations: {
          belongsTo: {
            users: {
              parent: true,
              localKey: 'userId',
              localField: 'users'
            }
          }
        }
      });
})
  .run(function(Usersettings, User) {

    Usersettings.findAll({ userId: 4 }). // GET /users/4/settings/ui
      then(function (response) {
          console.log(response);
      }).catch(function (response) {
          console.log(response);
      });

  })
})(window.angular);

0reactions
demisxcommented, Apr 2, 2015

Yeah, I was following the example in this issue first and got that error. Switching to DSHttpAdapter.defaults.deserialize made it work.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Dynamic outbound REST that consumes multiple endpoints
Hi,. I have 20+ integration end points. Assumption is all these integrations use REST APIs and the integration list can grow.
Read more >
Creating a dynamic endpoint selection pattern - IBM
Dynamic Endpoint Selection (DES) is an integration pattern for dynamic service routing. DES enables service requesters and service providers to connect ...
Read more >
Making Forms More Dynamic with REST API Endpoints
Making Forms More Dynamic with REST API Endpoints. 3.7K views 3 years ago. ProcessMaker. ProcessMaker. 2.19K subscribers. Subscribe.
Read more >
Routes and Endpoints | REST API Handbook
Endpoints are the destination that a route needs to map to. For any given route, you could have a number of different endpoints...
Read more >
Dynamic Endpoint of APIs depending on User actions
Hello P9 Community, Is there a way to modify an Endpoint of an API depending on Data or other inputs from the User?...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found