john-smilga/node-express-course

Tasks not showing on the browser

Closed this issue · 1 comments

yarcx commented

So after doing all the server-side codes and connecting it to the public file so I could see the list of my tasks on the browser, i noticed I was getting an error.
After debugging turns out the error was coming from here, "line number 11"
image

So the issue was we were trying to destructure tasks from the returned data, instead of renaming data to tasks,

const {data: {tasks}} = axios.get('api/v1/tasks') this is throws an error

const {data: tasks} = axios.get('api/v1/tasks') this works fine

Yes, it all depends on structure of the response in my case it was
res.json({tasks}) in your case it sounds like you have res.json(tasks)