TypeScriptFullStackShell icon indicating copy to clipboard operation
TypeScriptFullStackShell copied to clipboard

response.response is undefined

Open pp opened this issue 6 years ago • 0 comments

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.

pp avatar Oct 05 '19 13:10 pp