Fetch categories with subcategories in component

Hy i want to fetch categories and sub categories to my new component kindly guide me.
Thank you