Get the source_url of featured image
-
Hello,
I have install the plugin and I get the “better_featured_image” object.
I try to render on my JS front using “item.better_featured_image.source_url” in my request, but this does not return me the wished url.I get this error : Uncaught (in promise) TypeError: Cannot read property ‘source_url’ of null
getReferences() { return new Promise((resolve, reject) => { request.defaults.baseURL = this.baseUrl; request.get('posts?categories=46&per_page=6').then(response => { const data = [...response.data]; if (response.status === 200 && response.data.length > 0) { const filtered = { total: response.headers["x-wp-total"], totalPages: response.headers["x-wp-totalpages"], data: data.map(item => ({ id: item.id, title: item.title.rendered, content: item.content.rendered, excerpt: item.excerpt.rendered, slug: item.slug, image: item.better_featured_image.source_url })) }; resolve(filtered); } else { reject(response); } }); }); },
- The topic ‘Get the source_url of featured image’ is closed to new replies.