Skip to content

findById makes resource expect array (angular SDK) #279

Closed

Description

@pbrain19

Using the sdk I am trying to find an object by Id. My code is below.

Activity.findById($stateParams.id,function(err, activtiy) {})

When I call this I get this error which traces back to this https://docs.angularjs.org/error/$resource/badcfg?p0=array

An Id is unique so it should only expect 1.

Activity

  1. bajtos commented on May 26, 2014

    @bajtos
    Member

    Hi @pbrain19,

    You are calling the findById action with incorrect parameters.

    1. The first parameter must be an object containing request parameters.
    2. Angular $resource actions don't use the error-first convention for callbacks, you should to pass two functions instead.
    Activity.findById(
      { id: $stateParams.id },
      function(activity) { /* ... */ },
      function(err) { /* ... */ });

    See ngResource.$resource for more details.

  2. bajtos commented on May 26, 2014

    @bajtos
    Member

    I am closing the issue now. Please ask in loopback mailing list if you need more help to get you started.

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

Metadata

Metadata

Assignees

No one assigned

    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