I am currently working on a class that serves as a controller to execute a method when called from a route. In the list method, I am trying to assign a value to my dataStore attribute without specifying a particular type since I am unsure of what type it should be. The object that is supposed to provide this value is expected to come from req.body
.
This implementation is in TypeScript and the requests are being transmitted through Postman.
class RentController{
private dataStore:any;
public search(req:Request, res:Response){
this.dataStore= req.body;
res.send(this.dataStore);
}
}
Here is the request sent via Postman
Here is the response received via Postman
The error message that I encounter reads:
TypeError: Cannot set property 'dataStore' of undefined