Skip to content
This repository has been archived by the owner on Jan 2, 2024. It is now read-only.

Error on getting a collection by Id #175

Open
irineul opened this issue Dec 19, 2019 · 3 comments
Open

Error on getting a collection by Id #175

irineul opened this issue Dec 19, 2019 · 3 comments
Labels
bug Something isn't working

Comments

@irineul
Copy link

irineul commented Dec 19, 2019

  1. I create collection
  2. I run the GET (to return all collections), and it returns:
[
  {
    "id": "-LwU90TtYEcnFCmworbQ",
    "cnpj": "saease",
    "name": "esaes",
    "qty_spots": 1
  },
  {
    "id": "-LwUAxrOD3p3jOOEuU2d",
    "cnpj": "esasea",
    "name": "esaesa",
    "qty_spots": 1
  },
  {
    "id": "-LwUG_rxD2UX0B1snn81",
    "cnpj": "test",
    "name": "xjxjx",
    "qty_spots": 2
  }
]
  1. I run the endpoint GET /{id}:
    curl -X GET "http://localhost:3000/testing/-LwUG_rxD2UX0B1snn81" -H "accept: application/json"

  2. And is not possible to find the entity: "ENTITY_NOT_FOUND"

What can I do to fix that?

@henriquecarv
Copy link
Owner

If I'm not mistaken you should be encoding the filter parameters:

http://localhost:3000/testing?filter[where][id]=-LwUG_rxD2UX0B1snn81

Ref: https://loopback.io/doc/en/lb3/Where-filter.html

@irineul
Copy link
Author

irineul commented Dec 20, 2019

Hi @henriquecarv

I tried to do this too. It gives an error:

Unhandled error in GET /testing/?filter[where][id]=-LwUG_rxD2UX0B1snn81: 500 TypeError: models.map is not a function
    at ParkRepository.toEntities (/mobile-api-v2/mobile-api/node_modules/@loopback/repository/src/repositories/legacy-juggler-bridge.ts:507:19)
    at ParkRepository.find (/mobile-api-v2/mobile-api/node_modules/@loopback/repository/src/repositories/legacy-juggler-bridge.ts:375:27)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:189:7)

@sudipta-b
Copy link

sudipta-b commented May 29, 2020

I am having the same issue in loopback 4, any hints would be really helpful. @henriquecarv

@henriquecarv henriquecarv reopened this May 31, 2020
@henriquecarv henriquecarv added the bug Something isn't working label Jun 19, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants