#!/usr/bin/env node
/**
* Debug script to test the get_boards API call specifically
* This will help us identify the exact issue with the boards endpoint
*/
const { CannyClient } = require('../dist/client/canny.js');
const { CONFIG } = require('../dist/config/config.js');
async function debugBoardsAPI() {
console.log('π Debugging Canny Boards API...\n');
// Initialize client
const client = new CannyClient(CONFIG.apiKey, CONFIG.baseUrl);
console.log(`π‘ API Base URL: ${CONFIG.baseUrl}`);
console.log(`π API Key: ${CONFIG.apiKey?.substring(0, 8)}...`);
try {
console.log('\nπ§ͺ Testing getBoards() method...');
const boardsResponse = await client.getBoards();
console.log(`π Response Status: ${boardsResponse.status}`);
if (boardsResponse.error) {
console.log(`β Error: ${boardsResponse.error}`);
} else {
console.log(`β
Success! Found ${boardsResponse.data?.length || 0} boards`);
if (boardsResponse.data && boardsResponse.data.length > 0) {
console.log('\nπ Boards found:');
boardsResponse.data.forEach((board, index) => {
console.log(` ${index + 1}. ${board.name} (ID: ${board.id})`);
});
}
}
} catch (error) {
console.log(`π₯ Exception thrown: ${error.message}`);
console.log(`π Stack trace: ${error.stack}`);
}
// For comparison, let's also test search_posts which we know works
try {
console.log('\nπ§ͺ Testing searchPosts() for comparison...');
const searchResponse = await client.searchPosts('test', { limit: 1 });
console.log(`π Search Response Status: ${searchResponse.status}`);
if (searchResponse.error) {
console.log(`β Search Error: ${searchResponse.error}`);
} else {
console.log(`β
Search Success! Found ${searchResponse.data?.posts?.length || 0} posts`);
}
} catch (error) {
console.log(`π₯ Search Exception: ${error.message}`);
}
}
// Run the debug
debugBoardsAPI().catch(console.error);