AIO APEX
GPT-4Debugging

Assistente de depuração sistemática

Compartilhar:

Why this prompt matters

Systematic debugging is faster than guessing. This prompt mirrors how senior engineers approach problems: parse, hypothesize, verify, fix.

What we use it for

Debugging

Prompt

I'm encountering this error. Help me debug it systematically: 1) Parse the error message and identify the root cause, 2) List the top 3 most likely causes in order of probability, 3) For each cause, provide a diagnostic command or code snippet to verify, 4) Once identified, provide the fix and explain how to verify it worked.

Result

## Error Analysis: `TypeError: Cannot read properties of undefined (reading 'map')`

**Root Cause**: The `users` variable is `undefined` when `.map()` is called, meaning the API response didn't match the expected shape.

**Most Likely Causes:** 1. (70%) API returned `{ data: { users: [...] } }` but code expects `{ users: [...] }` 2. (20%) API call failed silently and returned undefined 3. (10%) Race condition: component renders before data loads

**Fix**: Add optional chaining and validate response shape: ```js const users = response?.data?.users ?? []; ```

Assistente de depuração sistemática

Uma abordagem passo a passo para encontrar e resolver bugs de forma eficiente.

Este prompt de IA foi projetado para ajudá-lo a obter os melhores resultados. Siga as instruções e personalize os parâmetros de acordo com suas necessidades específicas.

Para obter os melhores resultados, forneça contexto detalhado e especifique o formato de saída desejado. Experimente diferentes variações para encontrar a que melhor se adapta ao seu caso de uso.

Compartilhar:
Assistente de depuração sistemática | AIO APEX