Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Internal Server Error #328

Closed
oritwoen opened this issue Nov 6, 2017 · 3 comments
Closed

Internal Server Error #328

oritwoen opened this issue Nov 6, 2017 · 3 comments
Assignees
Labels
issue: bug Issue reporting a bug

Comments

@oritwoen
Copy link
Contributor

oritwoen commented Nov 6, 2017

Node.js version: 8.8.1
npm version: 5.5.1
Strapi version: 3.0.0-alpha.6.4
Operating system: Arch Linux

{"message":"An internal server error occurred","statusCode":500,"error":"Internal Server Error"}

Example All:
http://localhost:1337/letter

ERROR (5195 on inder): Cannot read property 'fetchAll' of undefined
    TypeError: Cannot read property 'fetchAll' of undefined
    at find (/home/inder/strapi/api/letter/controllers/Letter.js:18:51)
    at dispatch (/usr/lib/node_modules/strapi/node_modules/koa-router/node_modules/koa-compose/index.js:44:32)
    at next (/usr/lib/node_modules/strapi/node_modules/koa-router/node_modules/koa-compose/index.js:45:18)
    at dispatch (/usr/lib/node_modules/strapi/node_modules/koa-compose/index.js:42:32)
    at next (/usr/lib/node_modules/strapi/node_modules/koa-compose/index.js:43:18)
    at /usr/lib/node_modules/strapi/lib/middlewares/router/utils/routerChecker.js:28:11
    at dispatch (/usr/lib/node_modules/strapi/node_modules/koa-compose/index.js:42:32)
    at /usr/lib/node_modules/strapi/node_modules/koa-compose/index.js:34:12
    at dispatch (/usr/lib/node_modules/strapi/node_modules/koa-router/node_modules/koa-compose/index.js:44:32)
    at next (/usr/lib/node_modules/strapi/node_modules/koa-router/node_modules/koa-compose/index.js:45:18)
    at validator (/usr/lib/node_modules/strapi/node_modules/koa-router-joi/joi-router.js:327:38)
    at dispatch (/usr/lib/node_modules/strapi/node_modules/koa-router/node_modules/koa-compose/index.js:44:32)
    at next (/usr/lib/node_modules/strapi/node_modules/koa-router/node_modules/koa-compose/index.js:45:18)
    at parsePayload (/usr/lib/node_modules/strapi/node_modules/koa-router-joi/joi-router.js:253:62)
    at dispatch (/usr/lib/node_modules/strapi/node_modules/koa-router/node_modules/koa-compose/index.js:44:32)
    at next (/usr/lib/node_modules/strapi/node_modules/koa-router/node_modules/koa-compose/index.js:45:18)

Example One:
http://localhost:1337/letter/5a0032edcfd2ef118ac6b109

ERROR (5195 on inder): Cannot read property 'fetch' of undefined
    TypeError: Cannot read property 'fetch' of undefined
    at findOne (/home/inder/strapi/api/letter/controllers/Letter.js:31:51)
    at dispatch (/usr/lib/node_modules/strapi/node_modules/koa-router/node_modules/koa-compose/index.js:44:32)
    at next (/usr/lib/node_modules/strapi/node_modules/koa-router/node_modules/koa-compose/index.js:45:18)
    at dispatch (/usr/lib/node_modules/strapi/node_modules/koa-compose/index.js:42:32)
    at next (/usr/lib/node_modules/strapi/node_modules/koa-compose/index.js:43:18)
    at /usr/lib/node_modules/strapi/lib/middlewares/router/utils/routerChecker.js:28:11
    at dispatch (/usr/lib/node_modules/strapi/node_modules/koa-compose/index.js:42:32)
    at /usr/lib/node_modules/strapi/node_modules/koa-compose/index.js:34:12
    at dispatch (/usr/lib/node_modules/strapi/node_modules/koa-router/node_modules/koa-compose/index.js:44:32)
    at next (/usr/lib/node_modules/strapi/node_modules/koa-router/node_modules/koa-compose/index.js:45:18)
    at validator (/usr/lib/node_modules/strapi/node_modules/koa-router-joi/joi-router.js:327:38)
    at dispatch (/usr/lib/node_modules/strapi/node_modules/koa-router/node_modules/koa-compose/index.js:44:32)
    at next (/usr/lib/node_modules/strapi/node_modules/koa-router/node_modules/koa-compose/index.js:45:18)
    at parsePayload (/usr/lib/node_modules/strapi/node_modules/koa-router-joi/joi-router.js:253:62)
    at dispatch (/usr/lib/node_modules/strapi/node_modules/koa-router/node_modules/koa-compose/index.js:44:32)
    at next (/usr/lib/node_modules/strapi/node_modules/koa-router/node_modules/koa-compose/index.js:45:18)
@soupette soupette assigned soupette and lauriejim and unassigned soupette Nov 6, 2017
@Aurelsicoko
Copy link
Member

@Redni Can you show me the line 18 in the Letter.js controller? It should be

const data = await strapi.services.letter.fetchAll(ctx.query);

So, do you have a Letter.js service in ./api/letter/services/Letter.js?

@oritwoen
Copy link
Contributor Author

oritwoen commented Nov 7, 2017

@Aurelsicoko I discovered a problem. To tell the truth, the previous name was different, I changed it for these logs because I did not want to share a unique name so it was not used publicly. It turned out that I missed a significant problem.

When adding "New Content" in the admin panel, any type of name:
strapi.api
test.api

are automatically converted to:
strapiApi
testApi

then we have:

./api/strapiapi/controllers/StrapiApi.js
./api/strapiapi/models/StrapiApi.js
./api/strapiapi/services/StrapiApi.js

The appeals are as follows:

const data = await strapi.services.strapiApi.fetchAll (ctx.query);

So to summarize. Names that only consist of lowercase work perfectly. These consisting of small and large do not work at all.

@lauriejim lauriejim added issue: bug Issue reporting a bug framework labels Nov 9, 2017
@lauriejim
Copy link
Contributor

lauriejim commented Nov 9, 2017

Okay thank you for this issue, generated code is not completely correct.
The global model have to be Strapiapi or Testapi instead of StrapiApi
And in strapi object it's strapi.services.strapiapi or strapi.models.strapiapi instead of strapi.models.strapiApi.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
issue: bug Issue reporting a bug
Projects
None yet
Development

No branches or pull requests

4 participants