The module adds WP-API to your nuxt application.
The size of the library is 85,5 kB minified (26,5 kB gzipped).
-
Add
wp-nuxt
dependency using yarn or npm to your project -
Add
wp-nuxt
tomodules
section ofnuxt.config.js
{
modules: [
// Simple usage
'wp-nuxt',
// With options
['wp-nuxt', {
endpoint: 'https://wp.kmr.io/wp-json'
/* other options of WP-API */
}],
]
}
You can use the API of WP-API using the injected 'app.$wp'. (s. example)
<script>
export default {
async asyncData ({ app, store, params }) {
return { articles: await app.$wp.posts().perPage(10) }
}
}
</script>
Copyright (c) yashha