No json template defined (module does not exist) - link fixed

When i try returning /api/posts, i receive no “index” json template defined (module doesn’t exist) error. Ive finagled with the code for a while and am able to see where the problem is, but dont understand why json template can’t be rendered.

Code can be found here

Thank you for any help.

The problem seems to be that you defined HTML templates for your PostController through the PostHTML module but you expect a JSON response. So, currently you return HTML templates, not JSON. I’d suggest you run ‘mix phx.gen.json Posts Post posts title:text body:text’. This will create a JSON controller for you with a PostJSON module instead of a PageHTML module. Compare the differences between these two modules. You’ll see that you now return JSON instead of HTML

1 Like