0
I am having a problem sending a request, which comes out of my Typescript file, I send it to Insomnia and generates the error only after sending.
Typescript file :
import { Router } from 'express';
import { uuid } from 'uuidv4';
const appointmentsRouter = Router();
const appointments = [];
appointmentsRouter.post('/',(request, response) =>{
const { provider, date } = request.body;
const appointment = {
id: uuid(),
provider,
date,
};
appointments.push(appointment);
return response.json(appointment)
});
export default appointmentsRouter;
Requisition from the Insomnia:
{
"provider" : "Diego Fernandes",
"date" : "{% now 'iso-8601', '' %}"
}
Error generated after sending:
insert Typeerror: Cannot read Property 'Provider' of Undefined at /home/decco/projects/projectNode/src/Routes/appointments.routes.ts:9:19 at Layer.Handle [as handle_request] (/home/decco/projects/projectNode/node_modules/express/lib/router/layer.js:95:5) at next (/home/decco/projects/projectNode/node_modules/express/lib/router/route.js:137:13) At Route.Dispatch (/home/decco/projects/projectNode/node_modules/express/lib/router/route.js:112:3) at Layer.Handle [as handle_request] (/home/decco/projects/projectNode/node_modules/express/lib/router/layer.js:95:5) at /home/decco/projects/projectNode/node_modules/express/lib/router/index.js:281:22 At function.process_params (/home/decco/projects/projectNode/node_modules/express/lib/router/index.js:335:12) at next (/home/decco/projects/projectNode/node_modules/express/lib/router/index.js:275:10) at Function.Handle (/home/decco/projects/projectNode/node_modules/express/lib/router/index.js:174:3) at router (/home/decco/projects/projectNode/node_modules/express/lib/router/index.js:47:12) here