Currently my Nuxt.js application serves HTML pages defined in layouts, pages, routes and components.
Is it possible to render one single route / one page as a standard JSON Response? Is that possible? I mean do not render the HTML e.g. Tags - only pure JSON!
What I already tried:
- Created a completely clean layout (with basically only in it), no succcess, still HTML.
- Used
<pre>{{jsonObject}}</pre>
hoping to get plain JSON, no success.
Would be VERY happy, if somebody could tell me whether this is possible AT ALL or not?
CodePudding user response:
What you're looking for here, is an API.
Vue.js will render a template (compiled to render functions, generating a DOM tree) at the end, because it's aimed towards a frontend usage. If you want to render something like an API response with pure JSON, you need to look into Express or alike.