'before' method is undefined on expressjs
- Lingua principale
- JavaScript
- Stelle
- 7
- Fork
- 5
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
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)
```
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Direzione di ricerca
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.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- express, javascript, node.js
- Ambito
- api, backend
- Tipo di issue
- Bug
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 45/100