Connect Your Frontend
Use the CubeStack API to display data in your web application.Using Fetch API
For public cubes, no authentication is needed. Only public columns are returned.
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Fetch CubeStack data from your frontend application.
const API_URL = 'https://api.cubestack.app/api/v1/my-project';
async function getProducts() {
const response = await fetch(`${API_URL}/products`);
const { data } = await response.json();
return data;
}
import { useState, useEffect } from 'react';
function ProductList() {
const [products, setProducts] = useState([]);
useEffect(() => {
fetch('https://api.cubestack.app/api/v1/my-project/products')
.then(res => res.json())
.then(({ data }) => setProducts(data));
}, []);
return (
<ul>
{products.map(product => (
<li key={product.id}>{product.name} - ${product.price}</li>
))}
</ul>
);
}
export async function getStaticProps() {
const res = await fetch('https://api.cubestack.app/api/v1/my-project/products');
const { data } = await res.json();
return {
props: { products: data },
revalidate: 60
};
}
const response = await fetch(`${API_URL}/products`, {
headers: { 'X-Api-Key': process.env.CUBESTACK_API_KEY }
});
Was this page helpful?