ReferenceError: request is not defined
I got the same error but in a different context than yours; when I tried importing
import { Request } from 'express'
export class UserRequest extends Request {
user: UserEntity;
}
the problem was caused because of using class
instead of interface
This example is making use of third-party Request module.
You could also use the native request like so: require('http').request()
, if you want to, but I would say, that the request module is very common, and a good tool to use.
Your request
, which is commented out, points to express.request
. If used like request()
will throw an error, since it's not a function. So, you should really use the Request module, or adjust the code to use native http.request
.
Update 2020
The request module is deprecated now, so if you are reading this answer, use the native module or find a popular third-party library like Axios or others.
You have not installed request
module.
First install it npm install --save request
and then include it var request = require('request');