TypeScriptFullStackShell
TypeScriptFullStackShell copied to clipboard
response.response is undefined
In DemoController.ts you return json with the key message:
return res.status(OK).json({
message: DemoController.SUCCESS_MSG + name,
});
Therefore you should access response.message in App.tsx:
let response = await fetch('/api/say-hello/SeanMaxwell')
.then(res => res.json());
alert('Hi this is a response from the backend: ' + response.response);
Otherwise the alert will display undefined instead of the message.