Skip to content

Instantly share code, notes, and snippets.

@elephantsneverforget
Created February 8, 2024 13:36
Show Gist options
  • Save elephantsneverforget/5b04475a9357bcf9e898a5d746df4fb0 to your computer and use it in GitHub Desktop.
Save elephantsneverforget/5b04475a9357bcf9e898a5d746df4fb0 to your computer and use it in GitHub Desktop.
// Replace CUSTOMERID with the specific customer id & add your api key
const apiUrl = 'https://example.com/admin/api/2024-01/customers/CUSTOMERID.json';
async function fetchOrdersCount() {
const response = await fetch(apiUrl, {
method: 'GET',
headers: { 'Content-Type': 'application/json',
// Add your api key
}
});
const data = await response.json();
// Push event to CAPI
console.log('Orders Count:', data.customer.orders_count);
}
fetchOrdersCount();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment