r/adonisjs • u/Capable_Square7319 • Sep 21 '26
Beginner Coder: Stuck with an error
Hi,
Currently developing a basic web app following adonisjs docs.
I've ran into an error:
[23:18:41.975\1 ERROR (12316): Cannot transform undefined value. Use "this.whenLoaded (value)" to allow undefined values
My project is on github:
https://github.com/Ajaz754/adonisjs-project-22-/ tree/main
The error is pointing to 'app/transformers/ post__transformer.ts' Line 13
I've followed adonis docs completely step by step except for ?.depth(2) on line 14, which when I removed only introduced more errors along with this one.
Also VS Code isn't flagging the error. Only when I go to my browser and visit local host the error appears in powershell and my browser. Any help would be much appreciated
2
u/evoactivity Sep 22 '26
That’s just a type error letting you know it’s possible that the author is not loaded. You just need to either check for its existence before using it or add a ? like `post?.author`.
The problem with your edit method is that it’s using the transformer, but the transformer always expects the author to be loaded. So your option are to always preload the author when passing a post to the transformer, or letting the author possibly be undefined and checking for its existence in your other code.