Site icon Hip-Hop Website Design and Development

wrapping ‘rest_api_init’ in ‘is_admin()’ perform

i am create customized admin web page by way of add_menu_page, lets say that my customized web page has url

wp-admin/admin.php?web page=settings_page

then i am checki is_admin() perform by way of var_dump on my settings_page and it returns true – that is OK, however when i am wrap rest_api_init motion in if is_admin() assertion, like this:

if(is_admin()){
  add_action('rest_api_init',   [$this, 'myRegisterRoutesFunction']);
}

it returns me 404 - No route was discovered matching the URL and request technique. But when i take away if assertion, it really works fantastic. Cannot perceive why, thanks for the advices!