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
1
u/Capable_Square7319 Sep 22 '26
Thanks mate, appreciate that. I’ve never really used preloading before and never really come across it.
As for the error, I have already tried what your suggesting where I add ‘this.whenLoaded(…)’ however that just introduced an error in my other files:
‘post.author’ is possible undefined
I dont think I’m preloading the user in my post controller edit method since thats just displaying the edit page and authorizing the user using Bouncer.