Force new git SHA to avoid CI scientific notation bug. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
90 lines
3.2 KiB
TypeScript
90 lines
3.2 KiB
TypeScript
import axios from 'axios';
|
|
|
|
async function main() {
|
|
const clientId = '29dce682258145c6b1cf71027282d083';
|
|
const clientSecret = 'A57bB49AfD7F4233B1750a0B501B4E16';
|
|
const storeId = 'best';
|
|
|
|
// Try various Treez API endpoints for products
|
|
const endpoints = [
|
|
'https://headless.treez.io/v2.0/dispensary/' + storeId + '/ecommerce/products',
|
|
'https://headless.treez.io/v2.0/dispensary/' + storeId + '/ecommerce/menu',
|
|
'https://headless.treez.io/v2.0/dispensary/' + storeId + '/ecommerce/inventory',
|
|
'https://headless.treez.io/v2.0/dispensary/' + storeId + '/ecommerce/catalog',
|
|
'https://headless.treez.io/v2.0/dispensary/' + storeId + '/menu',
|
|
'https://headless.treez.io/v2.0/dispensary/' + storeId + '/products',
|
|
'https://api.treez.io/v2.0/dispensary/' + storeId + '/ecommerce/products',
|
|
'https://api.treez.io/v2.0/dispensary/' + storeId + '/products',
|
|
'https://selltreez.com/api/dispensary/' + storeId + '/products',
|
|
];
|
|
|
|
console.log('Testing Treez product endpoints...\n');
|
|
|
|
for (const url of endpoints) {
|
|
console.log('GET ' + url);
|
|
try {
|
|
const response = await axios.get(url, {
|
|
headers: {
|
|
'client_id': clientId,
|
|
'client_secret': clientSecret,
|
|
'Content-Type': 'application/json',
|
|
'Accept': 'application/json',
|
|
},
|
|
timeout: 10000,
|
|
});
|
|
|
|
console.log(' Status: ' + response.status);
|
|
const data = response.data;
|
|
|
|
if (Array.isArray(data)) {
|
|
console.log(' Array: ' + data.length + ' items');
|
|
if (data[0]) console.log(' Keys: ' + Object.keys(data[0]).slice(0, 10).join(', '));
|
|
} else if (data?.data && Array.isArray(data.data)) {
|
|
console.log(' data[]: ' + data.data.length + ' items');
|
|
if (data.data[0]) console.log(' Keys: ' + Object.keys(data.data[0]).slice(0, 10).join(', '));
|
|
} else {
|
|
console.log(' Type: ' + typeof data);
|
|
console.log(' Keys: ' + (typeof data === 'object' ? Object.keys(data).join(', ') : 'N/A'));
|
|
}
|
|
console.log('');
|
|
|
|
} catch (err: any) {
|
|
const status = err.response?.status || 'network error';
|
|
console.log(' Error: ' + status + '\n');
|
|
}
|
|
}
|
|
|
|
// Also check the working discounts endpoint for clues
|
|
console.log('\n=== CHECKING DISCOUNTS FOR PRODUCT REFERENCES ===\n');
|
|
|
|
try {
|
|
const response = await axios.get(
|
|
'https://headless.treez.io/v2.0/dispensary/' + storeId + '/ecommerce/discounts?excludeInactive=true&hideUnset=true&includeProdInfo=true',
|
|
{
|
|
headers: {
|
|
'client_id': clientId,
|
|
'client_secret': clientSecret,
|
|
},
|
|
}
|
|
);
|
|
|
|
const data = response.data?.data || response.data;
|
|
if (Array.isArray(data) && data.length > 0) {
|
|
console.log('Discounts: ' + data.length);
|
|
console.log('First discount keys: ' + Object.keys(data[0]).join(', '));
|
|
|
|
// Check if it has product info
|
|
if (data[0].products) {
|
|
console.log('\nHas products array: ' + data[0].products.length);
|
|
if (data[0].products[0]) {
|
|
console.log('Product keys: ' + Object.keys(data[0].products[0]).join(', '));
|
|
}
|
|
}
|
|
}
|
|
} catch (err: any) {
|
|
console.log('Error: ' + err.message);
|
|
}
|
|
}
|
|
|
|
main();
|