0
votes

been playing around with a simple blog built with JSONPlaceholder and Nuxt.js

Everything seems fine, I've got an archive and single blog posts working fine but when deployed on Netlify I can see that the browser is still doing API calls to JSONPlaceholder even though all the pages are built static and I can see they already have the content within the HTML.

I used the routes method within generate in the nuxt config to create the 100 html files based upon the JSONPlaceholder /posts results.

Here's the Netlify link: REMOVED.

And a public repo: https://bitbucket.org/oneupstudio/api-test/src/master/

Anything I've missed?

2

2 Answers

-1
votes

Nuxt.js doesn't support 'full static generation' yet, check this RFC.

For now, you can use this module in order to make your JSON requests static.

-1
votes

Nuxt currenty supports proper static generation of websites. Although one has to be aware of payload param in asyncData. So if payload is present that indicates that static generator is at work and no api calls should be made in this case:

async asyncData ({ params, error, payload }) {
  if (payload) return { user: payload }
  else return { user: await backend.fetchUser(params.id) }
}

Read more on this here.


RFC mentioned by @DreadMinder will further improve on this, but you can already do full static websites with Nuxt.