diff --git a/server/routes.ts b/server/routes.ts index 7cdaac5..1f18f4f 100644 --- a/server/routes.ts +++ b/server/routes.ts @@ -394,6 +394,11 @@ export async function registerRoutes(app: Express): Promise { } }); + // Debug the response structure + console.log("IUCN API response structure:", + Object.keys(response.data), + response.data.result ? `Result has ${response.data.result.length} items` : "No result property"); + return res.json({ success: true, data: response.data, @@ -471,12 +476,20 @@ export async function registerRoutes(app: Express): Promise { const taxonId = taxaResponse.data.result[0].taxonid; // Now retrieve the threats using the taxon ID - const threatsResponse = await axios.get(`https://apiv4.iucnredlist.org/api/v4/threats/species/id/${taxonId}`, { + const threatsResponse = await axios.get(`https://apiv4.iucnredlist.org/api/v4/threats`, { headers: { "Authorization": `Bearer ${activeToken.iucnToken}` + }, + params: { + taxonid: taxonId } }); + // Debug the response structure + console.log("IUCN Threats API response structure:", + Object.keys(threatsResponse.data), + threatsResponse.data.result ? `Result has ${threatsResponse.data.result.length} items` : "No result property"); + return res.json({ success: true, data: threatsResponse.data, @@ -554,12 +567,20 @@ export async function registerRoutes(app: Express): Promise { const taxonId = taxaResponse.data.result[0].taxonid; // Now retrieve the habitats using the taxon ID - const habitatsResponse = await axios.get(`https://apiv4.iucnredlist.org/api/v4/habitats/species/id/${taxonId}`, { + const habitatsResponse = await axios.get(`https://apiv4.iucnredlist.org/api/v4/habitats`, { headers: { "Authorization": `Bearer ${activeToken.iucnToken}` + }, + params: { + taxonid: taxonId } }); + // Debug the response structure + console.log("IUCN Habitats API response structure:", + Object.keys(habitatsResponse.data), + habitatsResponse.data.result ? `Result has ${habitatsResponse.data.result.length} items` : "No result property"); + return res.json({ success: true, data: habitatsResponse.data,