Files
cannaiq/backend/scripts/test-treez-headless-api.ts
Kelly 698995e46f chore: bump task worker version comment
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>
2025-12-14 02:02:30 -07:00

58 lines
1.6 KiB
TypeScript

import axios from 'axios';
async function main() {
const storeId = 'best';
const baseUrl = `https://headless.treez.io/v2.0/dispensary/${storeId}`;
// Try various endpoints
const endpoints = [
'/ecommerce/discounts?excludeInactive=true&hideUnset=true&includeProdInfo=true',
'/ecommerce/products',
'/products',
'/menu',
'/inventory',
'/catalog',
];
console.log('Testing Treez Headless API endpoints...\n');
for (const endpoint of endpoints) {
const url = baseUrl + endpoint;
console.log('GET ' + url);
try {
const response = await axios.get(url, {
headers: {
'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 length: ' + data.length);
if (data.length > 0) {
console.log(' First item keys: ' + Object.keys(data[0]).join(', '));
console.log(' Sample: ' + JSON.stringify(data[0]).slice(0, 300));
}
} else if (typeof data === 'object') {
console.log(' Keys: ' + Object.keys(data).join(', '));
console.log(' Sample: ' + JSON.stringify(data).slice(0, 500));
}
console.log('');
} catch (err: any) {
console.log(' Error: ' + (err.response?.status || err.message));
if (err.response?.data) {
console.log(' Data: ' + JSON.stringify(err.response.data).slice(0, 200));
}
console.log('');
}
}
}
main();