Closed Arindam200 closed 3 months ago
Enhance API integration by checking for missing API keys and improving error logging for better issue identification and graceful failure.
Check for Missing API Keys:
Improve Error Logging:
const openaiApiKey = process.env.OPENAI_API_KEY; const mem0ApiKey = process.env.MEM0_API_KEY; if (!openaiApiKey || !mem0ApiKey) { console.error('Missing API keys:', { openaiApiKey: !!openaiApiKey, mem0ApiKey: !!mem0ApiKey, }); return new Response('Missing API keys', { status: 500 }); } const mem0Response = await fetch('https://api.mem0.ai/v1/memories/search/', { method: 'POST', headers: { 'Content-Type': 'application/json', Authorization: `Token ${mem0ApiKey}`, }, body: JSON.stringify({ query: `What do you know about ${body.input}`, user_id: user.user.email, }), }); if (!mem0Response.ok) { const errorText = await mem0Response.text(); console.error('Error fetching memories:', { status: mem0Response.status, statusText: mem0Response.statusText, errorText: errorText, }); return new Response('Error fetching memories', { status: 500 }); }
I want to work on this
Description:
Enhance API integration by checking for missing API keys and improving error logging for better issue identification and graceful failure.
Improvements:
Check for Missing API Keys:
Improve Error Logging:
Improved Code:
Note:
I want to work on this