'before' method is undefined on expressjs
- Vorherrschende Sprache
- JavaScript
- Sterne
- 7
- Forks
- 5
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
I am using `kontroller` with an expressapp. Here is the [controller](https://github.com/ktkaushik/kontroller_sample/blob/master/controllers/posts_controller.js) i created named as `posts_controller.js`
In here, i keep getting an error saying that `before` is undefined.
```
before(think, {only: 'accelerate'});
^
TypeError: Property 'before' of object function Controller() {
if (!(this instanceof Controller)) {
return BaseController.route(arguments[0]);
}
BaseController.call(this);
} is not a function
at Object. (/Users/kaushik/dev/my_repos/kontroller_sample/controllers/posts_controller.js:4:8)
at Module._compile (module.js:449:26)
at Object.Module._extensions..js (module.js:467:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:362:17)
at require (module.js:378:17)
at Object. (/Users/kaushik/dev/my_repos/kontroller_sample/app.js:11:13)
at Module._compile (module.js:449:26)
at Object.Module._extensions..js (module.js:467:10)
```
Beitragsleitfaden
Für dieses Repository ist kein Beitragsleitfaden indexiert
Rechercherichtung
The error occurs when calling `before` in a controller file. Check the kontroller library's source to see if `before` is a method exposed on the Controller prototype or a separate module. Look at how other controllers use it, and verify the import/require statements. The fix likely involves ensuring the correct function is imported or the controller inherits properly.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- express, javascript, node.js
- Bereich
- api, backend
- Issue-Typ
- Bug
- Schwierigkeit
- 2/5
- Geschätzter Aufwand
- 1-3 Stunden
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 45/100