Tip:
Always remember to replace
API_SECRETin the Bearer Token andproject-idin the URL with the correct values from the Apito console.
If you are unsure where to find your API secrets and endpoints for your project, visit this page.
AxiosAxios is a powerful JavaScript library for making HTTP requests to Apito's REST API tools and database API endpoints from Node.js or XMLHttpRequests from the browser. When integrating with our instant API builder, Axios supports the Promise API native to ES6, can intercept HTTP requests and responses, enables client-side protection against XSRF, and has the ability to cancel requests to your database API.
const token = 'apito-api-secret';
axios.get('https://api.apito.io/secured/rest/project', {
headers: {
'Authorization': `Bearer ${token}`
}
})
.then((res) => {
console.log(res.data)
})
.catch((error) => {
console.error(error)
})
FetchThe Fetch API provides a JavaScript interface for accessing and manipulating Apito's REST API tools and database API endpoints. When working with our API builder platform, Fetch provides a global fetch() method that offers an easy, logical way to fetch resources asynchronously from your instant API across the network.
const token = 'apito-api-secret';
fetch('https://api.apito.io/secured/rest/project', {
headers: {
Authorization: `Bearer ${token}`
}
}).then(res => res.json())
.then(json => console.log(json));