Object.keys null 🟨 JavaScript

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

  1. Default to {}: Object.keys(obj ?? {})
  2. Check data has loaded
  3. Validate API responses

Detailed fix by platform

JavaScript

  1. const keys = Object.keys(response.meta ?? {});

How to diagnose

  1. Call — Which Object.* call?
  2. 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.