WP Rest API not working

First you’ve to Check if the WordPress REST API is enabled or not

The best way to check is to visit this URL: https://yoursite.com/wp-json.
If you see some JSON response, REST API is enabled.
If it’s showing some error page or returns to home page, REST API is not enabled. Then we’ve to enable it first.

In this case, you’ve to Enable Permalinks

  1. Visit your page’s admin page (Visit https://yoursite.com/wp-json)
  2. settings > Permalinks (visit https://yoursite.com/wp-admin/options-permalink.php)
  3. Make sure Plain is not selected
  4. Choose Post Name (it’s a best one)
  5. Then click on Save Changes. That will rewrite/repair your .htaccess

More info