TypeError: ctx.onerror is not a function
See original GitHub issueEnvironment
- Nodejs: 8.11.1
- Koa: 2.5.1
const onerror = err => ctx.onerror(err);
^
TypeError: ctx.onerror is not a function
at Array.onerror (./server/node_modules/koa/lib/application.js:147:32)
at listener (./server/node_modules/on-finished/index.js:169:15)
at onFinish (./server/node_modules/on-finished/index.js:100:5)
at callback (./dist/server/node_modules/ee-first/index.js:55:10)
at ServerResponse.onevent (./server/node_modules/ee-first/index.js:93:5)
at emitNone (events.js:111:20)
at ServerResponse.emit (events.js:208:7)
at onFinish (_http_outgoing.js:720:10)
at _combinedTickCallback (internal/process/next_tick.js:131:7)
at process._tickCallback (internal/process/next_tick.js:180:9)
How to fix it?
- Replace:
const onerror = err => ctx.onerror(err);
- With:
const onerror = ctx.onerror;
paragraph removed by fl0w
Issue Analytics
- State:
- Created 5 years ago
- Reactions:4
- Comments:8 (1 by maintainers)
Top Results From Across the Web
Node 8 + Typescript + Koa + koa-Router throws "TypeError
unfortunately, it throws TypeError: ctx.onerror is not a function all the time. Following the examples on GitHub for koa-router ...
Read more >TypeError: "x" is not a function - JavaScript - MDN Web Docs
The JavaScript exception "is not a function" occurs when there was an attempt to call a value from a function, but the value...
Read more >koa ctx.onerror is not a function - 掘金
解决方法问题是在bodyParse 用法上面改成。。。。。。。。。。。。。。。。。。。。。。。。。。。。。
Read more >How to Handle JavaScript Uncaught TypeError: “x” is Not a ...
The Javascript TypeError: "x" is not a function occurs when calling a function on a value or object, which is not actually a...
Read more >ctx.onerror is not a function"-node.js - appsloveworld
Coding example for the question Node 8 + Typescript + Koa + koa-Router throws "TypeError: ctx.onerror is not a function"-node.js.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I found out what my problem was.
@und3fined perhaps this or something like this was your issue?
This is bug with
bodyParser
(koa-bodyparser) =))