Add debug logging to frontend and backend for IUCN API responses.
Replit-Commit-Author: Agent Replit-Commit-Session-Id: e931b5ab-041b-42e7-baf1-50017869cef6 Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/e19c6a51-7e4c-4bb8-a6a6-46dc00f0ec99/8e2c4d57-ae11-4942-8aaf-e0f64235db14.jpg
This commit is contained in:
@ -74,6 +74,16 @@ export default function ResultsContainer({
|
||||
queryFn: async () => {
|
||||
if (!currentSpecies?.full_name) return null;
|
||||
const response = await apiClient.getIucnSpeciesByName(currentSpecies.full_name);
|
||||
|
||||
// Debug log
|
||||
console.log("IUCN Species API response:", response);
|
||||
if (response.success && response.data) {
|
||||
console.log("IUCN response data structure:", Object.keys(response.data));
|
||||
if (response.data.result) {
|
||||
console.log("IUCN result items:", response.data.result.length);
|
||||
}
|
||||
}
|
||||
|
||||
return response.success ? response.data : null;
|
||||
},
|
||||
enabled: !!currentSpecies?.full_name,
|
||||
|
@ -32,6 +32,14 @@ export default function SpeciesTabs({
|
||||
const { toast } = useToast();
|
||||
const [activeTab, setActiveTab] = useState("overview");
|
||||
|
||||
// Debug logging for IUCN data
|
||||
useEffect(() => {
|
||||
console.log("SpeciesTabs received iucnData:", iucnData);
|
||||
console.log("SpeciesTabs received iucnThreats:", iucnThreats);
|
||||
console.log("SpeciesTabs received iucnHabitats:", iucnHabitats);
|
||||
console.log("SpeciesTabs received iucnMeasures:", iucnMeasures);
|
||||
}, [iucnData, iucnThreats, iucnHabitats, iucnMeasures]);
|
||||
|
||||
// Handle copy API response to clipboard
|
||||
const handleCopyResponse = async () => {
|
||||
try {
|
||||
|
@ -658,12 +658,20 @@ export async function registerRoutes(app: Express): Promise<Server> {
|
||||
const taxonId = taxaResponse.data.result[0].taxonid;
|
||||
|
||||
// Now retrieve the conservation measures using the taxon ID
|
||||
const measuresResponse = await axios.get(`https://apiv4.iucnredlist.org/api/v4/measures/species/id/${taxonId}`, {
|
||||
const measuresResponse = await axios.get(`https://apiv4.iucnredlist.org/api/v4/measures`, {
|
||||
headers: {
|
||||
"Authorization": `Bearer ${activeToken.iucnToken}`
|
||||
},
|
||||
params: {
|
||||
taxonid: taxonId
|
||||
}
|
||||
});
|
||||
|
||||
// Debug the response structure
|
||||
console.log("IUCN Measures API response structure:",
|
||||
Object.keys(measuresResponse.data),
|
||||
measuresResponse.data.result ? `Result has ${measuresResponse.data.result.length} items` : "No result property");
|
||||
|
||||
return res.json({
|
||||
success: true,
|
||||
data: measuresResponse.data,
|
||||
|
Reference in New Issue
Block a user