Back

save post

  • 0
  • Databases
mijn_bassie
23 Jan, 2024, 02:24

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 );

TL;DR
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 (`?.`).
mijn_bassie
23 Jan, 2024, 02:25

My user is: tonymelony

mijn_bassie
23 Jan, 2024, 02:25

and project id = 65a321d6b97507a5464a

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more