We have just started up a project in Umbraco Heartcore to be able to set up a headless website for our company. I have set up a simple project with a Document Type “Page Template” which holds a string slug and a block list of blocks. I have then created a sample Hero block as a separate Document Type.
Now in the Content part I set up a new Page Template called “Contact” and added the slug “contact” and a Hero block with the given information.
In Vue I now want to get the page data from their API and set up this apiClient.js:
import axios from 'axios';
const apiClient = axios.create({
baseURL: import.meta.env.VITE_API_URL,
headers: {
'Content-Type': 'application/json',
'Api-Key': import.meta.env.VITE_API_KEY,
'Umb-Project-Alias': import.meta.env.VITE_PROJECT_ALIAS,
'api-version': '2'
},
});
export default apiClient;
Where my .env is like this:
VITE_PROJECT_ALIAS=dev-web
VITE_API_URL=https://cdn.umbraco.io
VITE_API_KEY=api-key-here
I try to fetch the data by this but it doesn’t give me the page data, just some meta data and other things:
const response = await apiClient.get('/content');
console.log(response)
How do I get the current page data by slug so that I in Vue can loop through the page blocks and print them to the browser?
PS. In “normal” Umbraco I could do something like this mywebsite.com/umbraco/delivery/api/v2/content
but it seems like Heartcore uses some other endpoints since it is based in their cloud.