I'm using Nuxt.js to render content from a separate WordPress installation. I've managed to set up a dynamic page that grabs the correct content based on the url path, however I don't know how to grab the featured image, as featuredmedia key name includes a colon:
wp:featuredmedia { href: 'root.com/linktoimage' }
Nuxt.js returns:
'error Parsing error: Unexpected token, expected'
How can I get Nuxt.js to read this correctly without returning an error? I additionally need to alter the returned link as the actual end point for the API is different from the link, though I think this will be relatively easy to resolve on my own.
Appreciate any help I can get on this. Thanks.
EDIT
The whole script in this page component is:
<script>
import axios from 'axios'
export default {
async asyncData (context) {
let { data } = await axios.get('https://rootdomain.com/cms/index.php/wp-json/wp/v2/posts?slug=' + context.params.post)
return {
data,
featuredImageURL: data[0]._links.wp:featuredmedia[0].href,
title: data[0].title.rendered,
content: data[0].content.rendered
}
}
}
</script>
The data, title, and content are being grabbed and rendered as expected. The issue seems to lie in how Nuxt.js reads that colon in the target key (wp:featuredmedia).