Skip to content

Using loopback-connector-remote to call custom methond in another loopback service doesn't create correct URL #46

@malave

Description

@malave

I'm trying to connect 2 loopback services, let's say A and B, using loopback-connector-remote datasource.

On B I have this custom remote method:

/api/B/myModel/myMethod/{id}

This method works fine if I access the API explorer on B service.

Then on A service I want to access this method so I created the following configuration (which is the same on B too) on the remote model object:

 myModel.remoteMethod(
       'myMethod',
        {
         http: {path: '/myMethod/:id', verb: 'get'},
          accepts: [
           {arg: 'id', type: 'number', required: true}
          ],
          returns: {type: 'object', root: true}
        }
     );

From A I can do any call to B like find, findById, etc. But When I call this custom method I get this error on A:

strong-remoting:rest-adapter Error in GET /myModel/myMethod/1231: Error: id must be a number

And looking at the logs in B I saw that A is calling the service like this:

strong-remoting:rest-adapter Error in GET /myModel/myMethod/:id?id=1231: Error: id must be a number

Why is strong-remoting or loopback-connector-remote not replacing the id correctly when the URL is created? Did I missed something on the configuration?

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions