TypeError: Cannot convert undefined or null to object
Object.keys/entries/assign was called with undefined or null.
Exact message you may see
Cannot convert undefined or null to object
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 not fixed?
Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:
Similar errors
Most viewed in JavaScript
- Failed to fetch TypeError: Failed to fetch / NetworkError when attempting to fetch resource
- module MIME type Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "text/html"
- QuotaExceededError QuotaExceededError: Failed to execute 'setItem' on 'Storage': Setting the value exceeded the quota
Other ways to find it
Where this error sits
Origin: On your device. Errors that are often confused with or caused by this one (click to open):
🧠 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.
💬 What worked for others
No tips yet — did something else fix this for you?
Share what worked for you
Tips are checked by an editor before they appear. Links are removed.
Did this fix work for you?
Report a correction or suggest an improvement
Last updated 9 Oct 2026