I want to implement a Discord login on a website. But I have a few issues. When I start the application with node oauth.js in the terminal, no error popped up. But then, when I click on authorize on the Discord website, the following error pops up:
TypeError: fetch is not a function
at ...\oauth.js:49:5
at Layer.handle [as handle_request] (...\node_modules\express\lib\router\layer.js:95:5)
at next (...\node_modules\express\lib\router\route.js:137:13)
at Route.dispatch (...\node_modules\express\lib\router\route.js:112:3)
at Layer.handle [as handle_request] (...\node_modules\express\lib\router\layer.js:95:5)
at ...\node_modules\express\lib\router\index.js:281:22
at Function.process_params (...\node_modules\express\lib\router\index.js:335:12)
at next (...\node_modules\express\lib\router\index.js:275:10)
at ...\node_modules\body-parser\lib\read.js:130:5
at invokeCallback (...\node_modules\raw-body\index.js:224:16)
I can't find the error in my code... It's something to do with fetch
Any ideas?
From looking at the fiddle, I can't see any problem except the way you have formatted your fetch import.
const fetch = require('node-fetch');
Try something like that instead of importing it.