Hello everyone,
I attempted to make a content api call from the browser using the content api docs.
the call to http://localhost:2368’ and https://demo.ghost.io both resulted in the same error displayed below.
here is the snippet:
{{#contentFor "scripts"}}
<script src="https://unpkg.com/@tryghost/content-api@1.0.0/umd/content-api.min.js"></script>
<script>
const api = new GhostContentAPI({
url: 'https://demo.ghost.io',
key: '22444f78447824223cefc48062',
version: 'v2'
});
// fetch 5 posts, including related tags and authors
api.posts
.browse({limit: 5, include: 'tags,authors'})
.then((posts) => {
posts.forEach((post) => {
console.log(post.title);
});
})
.catch((err) => {
console.error(err);
});
</script>
{{/contentFor}}
Any feedback is appreciated.
Thank you