mijn_bassieOriginal post
Rank 1: Thread
i get an error while finding a save post, but in the attribute the save exist under user.
error is: TypeError: Cannot read properties of null (reading 'find')
line: const savedPostRecord = currentUser?.save.find( (record: Models.Document) => record.post.$id === post.$id );
Summary
Developers are experiencing an error while attempting to find a saved post. The error message indicates a TypeError, specifically "Cannot read properties of null (reading 'find')." The problematic line of code is provided:
```const savedPostRecord = currentUser?.save.find(
(record: Models.Document) => record.post.$id === post.$id
);```
A possible solution could be to check if both `currentUser` and `currentUser.save` exist before attempting to call the `.find()` method. This could be achieved using conditional statements or optional chaining (`?.`).