Getting a GET error in console – 404 not found for wp-json
The URL you’re using is not the URL that you’ve registered. This code: register_rest_route( ‘news’, ‘/news’, array( ‘methods’ => ‘GET’, ‘callback’ => ‘custom_api_get_news_callback’ )); Registers this URL: http://localhost:8888/una/wp-json/news/news But you’re sending requests to http://localhost:8888/una/wp-json/news/all-posts Nowhere in your code have you defined an all-posts endpoint. You either need to change /news in register_rest_route() to /all-posts, or … Read more