# Why does `getMarkdownFiles` return an empty array in `onLoad()`?
#obsidian/api/faq
---
**First off:** Don't call `getMarkdownFiles()` inside your plugin's `onLoad` function. On startup, Obsidian asynchronously walks through all the folders and files in your vault directory and registers them with the [[Vault]]. Your plugin's `onLoad` is called before that.
If your plugin needs to iterate through the vault on startup, you should do so within the [`onLayoutReady`](https://github.com/obsidianmd/obsidian-api/blob/81ab85ade4552c9116c1e10d009127e62019c923/obsidian.d.ts#L2846) callback, which is fired after the Vault has been initialized and the files have been resolved.