TypeError: Cannot convert undefined or null to object
Object.keys/entries/assign was called with undefined or null.
Seen on:
JavaScript
Meaning
Object helpers require an object. The value you passed hasn’t loaded or the property doesn’t exist.
Common causes
- Object.keys(data.items) where items is undefined
- Object.assign(null, …)
- Optional API fields
⚡ Quick fix
- Default to {}: Object.keys(obj ?? {})
- Check data has loaded
- Validate API responses
Detailed fix by platform
JavaScript
const keys = Object.keys(response.meta ?? {});
How to diagnose
- Call — Which Object.* call?
- Value — Why undefined?
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
Was this page helpful?
Report a correction or suggest an improvement
Last updated 2 Oct 2026