StrongLoop Explorer Model Configuration Error

I am trying to create an example of a strong loop application and I get the following error when I try to try post api using / explorer.

"Cannot call AccessToken.findById(). The findById method has not been setup.. The PersistedModel has not been correctly attached to a DataSource." 

I skipped and installed slc loopback: acl with the following settings:

 "acls": [ { "accessType": "*", "principalType": "ROLE", "principalId": "admin", "permission": "ALLOW" } ], 

However, these settings do not seem to apply to my model.

+5
source share
2 answers

I had the same problem: for me, it decided to remove my local storage browser (on the "Resources" tab in the development tools). The explanation for this was that I used another loopback application that uses token-based authentication.

+1
source

I have the same error message and the solution for me was to edit model-config.json with the value for "datasourse" on my entity:

  "cat": { "dataSource": "mydb", "public": true } 

All files:

model-config.json

 { "_meta": { "sources": [ "loopback/common/models", "loopback/server/models", "../common/models", "./models" ], "mixins": [ "loopback/common/mixins", "loopback/server/mixins", "../common/mixins", "./mixins" ] }, "cat": { "dataSource": "mydb", "public": true } } 

datasourse.json

 { "mydb": { "host": "localhost", "port": 27017, "url": "", "database": "test", "password": "", "name": "", "user": "", "connector": "mongodb" } } 

I am working on an example with loopback 3.x and I had to install the following node package to enable connection with mongodb

npm install loopback-connector-mongodb --save

If you need more information, you can refer to the official document at https://loopback.io/doc/en/lb3/MongoDB-connector.html

0
source

Source: https://habr.com/ru/post/1214762/


All Articles