//PROBLEM
Even after doing findAll({include : [users]}) in the showAllPosts() function .
for reference : Time is 1hr 27 min
sir did showAllPost() and i was able to do show and result was visible for post title and body
and in my user database the value of USERNAME is not null so why is this error coming.
//DATABASE ENTRY
select * from users;
±—±-----------------±--------------------±--------------------+
| id | username | createdAt | updatedAt |
±—±-----------------±--------------------±--------------------+
| 1 | plausible-bowl | 2022-03-01 07:53:22 | 2022-03-01 07:53:22 |
| 2 | electronic-piano | 2022-03-01 07:53:22 | 2022-03-01 07:53:22 |
±—±-----------------±--------------------±--------------------+
//ERROR SHOWING
Executing (default): SELECT post
.id
, post
.title
, post
.body
, post
.createdAt
, post
.updatedAt
, post
.userId
, user
.id
AS user.id
, user
.username
AS user.username
, user
.createdAt
AS user.createdAt
, user
.updatedAt
AS user.updatedAt
FROM posts
AS post
LEFT OUTER JOIN users
AS user
ON post
.userId
= user
.id
;
/Users/aman/Web Development/Online _FullStackWebD/Lecture8-Social_Media_App/src/controllers/post.js:37
${p.title}\nauthor:${p.user.username}\n${p.body}\n===========\n
^
TypeError: Cannot read properties of null (reading ‘username’)
at task (/Users/aman/Web Development/Online _FullStackWebD/Lecture8-Social_Media_App/src/controllers/post.js:37:36)
at processTicksAndRejections (node:internal/process/task_queues:96:5)