@TomJNowell pointed you the way to go. You have to enqueue a JS file, and within this JS file you can use any technique to do the REST request, like an XMLHttpRequest
object or the fetch
API. The REST API itself, of course, is part of WordPress, and defined with register_rest_route()
. It is also something you have to provide either within the theme or within a plugin.
Both the JS and the REST API should be part of the same component – i.e. the theme or a plugin.
how do I call an external API hosted on RapidAPI
A web browser does not allow JS functions to invoke a request to another domain name than the originating one.
Related Posts:
- Does something like is_rest() exist
- REST API purpose?
- WP REST API — How to change HTTP Response status code?
- Search WP API using the post title
- Displaying a page built with Elementor using the REST API [closed]
- Understanding SHORTINIT with WordPress 5
- Does pre_get_posts affect REST API responses?
- wordpress wp-json prefix issue
- Get blog title with REST v2
- Filter post_content before loading in Gutenberg editor
- Create post using rest api with html content
- rest_post_query on multiple post types?
- Wp Rest Api Custom Endpoint for page subpages
- How should an old API version be deprecated gracefully?
- WP REST API returns incorrect data?
- WP 5.5 Fatal Error – get_rest_controller() in rest-api.php
- REST API GET users
- WP_REMOTE_POST Requests are being blocked by API provider [closed]
- wp_get_object_terms() returns invalid taxonomy inside rest_api_init hook
- Is it posible to use wp.data.select(‘core’) outside a block?
- Can you Use the Rest API to query a custom database table
- Is there anyway to format my EndPoint URL in WordPress?
- Return WP_Error as WP_REST_Response
- Authenticating with REST API
- Make authorization mandatory on custom routes
- Custom Rest API POST endpoint with conditionally required parameters
- What is the meta field in the response of the user REST API?
- Is there any way to clear cache when making REST API request?
- how to avoid timeouts with remote API requests?
- Custom API endpoint to create gallery for post
- Register REST route with a multi-value parameter
- How do I add meta when creating a post with rest api?
- rest_api_init is run on every rest call to endpoint
- WordPress + REST API v2 and private pages Load by slug
- Change permissions on REST api?
- PHP: authenticate for a REST request?
- Is it Ok to restrict Access-Control-Allow-Origin for /wp-json requests?
- Validate rest-api call on create
- Authenticate current user to REST API
- Get a remote post ID via API given URL
- rest api endpoint – accept diacritic characters
- Core function to check if a rest namespace exists
- WordPress REST API rest_comment_invalid_author Sorry, you are not allowed to edit ‘author’ for comments
- How to delete user using rest api without reassigning
- Custom WP API endpoint NULL body data
- Accessing private posts through REST API, same code that works in remote doesn’t in local
- Rest API: trouble receiving response through script (browser and Postman display correctly)
- Advanced Access Manager: RESTful endpoint to refresh token
- `WP_REST_Controller::get_endpoint_args_for_item_schema` Does Not Set `required` Property from Schema
- Extending REST API responses
- Error message: Response is not a valid JSON response
- How to use query parameters, as “_fields”, to filter data inside an array in the REST API?
- WordPress server banning IP
- How to display relations via wordpress Rest API
- How to add Relations of a CCT from JetEngine via WordPress Rest API
- WP Rest_API- Post request for images returns empty
- Fetching WordPress Private Posts, Public Posts Via Default REST API Endpoint
- Pass multiple tags slug to rest API
- Return a WP_REST_Response from an inner function (and not from the root callback)
- register_rest_route with method POST but in wp-json/ is showing GET
- wp_nonce vs jwt
- Rest Api fetching only one random post
- Accessing Custom REST endpoint with rest_do_request()
- How to add taxonomy to a post using WP REST API?
- Got Blank issue for get data from /wp-json/v2/post
- How do i POST to WordPress rest API from the same domain?
- WP CLI in WP 5.3 with PHP 7.4
- Get wordpress post with featured image, category and tag from WordPress API
- Extract XML/JSON element from Zillow API response and populate into Gravity Forms field
- REST API and Loopback error
- Rest API: Register and Login errors aren’t specific
- How can I secure my custom rest api endpoint or add under a already existing rest group
- WordPress single page website redirect to index.html
- How to get the most recently updated orders via the REST API?
- Fetching all users that didn’t post with rest api (current version 2)
- Calling a python script from custom wordpress rest api returns null
- WordPress RESTAPI – Restrict unknown
- WordPress Rest API Error 502
- Custom rest API route not passing data along
- Fix Characters WordPress Ionic App
- How to filter wp-json/wp/v2/users response on custom metas?
- Can we use website data which is having wp rest api plugin?
- WP Rest API V2 OR Operator in URL
- GET request for media files in WP REST API 2 results in an empty array
- how can I add an URL parameter to a rest route using register_rest_route()?
- Is it possible to bulk update a table using WP Rest API?
- Call to undefined function upload_is_user_over_quota()
- API wp-json/wp/v2/pages/ returns a different result if page is specified
- Update post / page using API + python
- Is my WordPress site handing out sensitive information/misconfigured?
- Delete row from table using custom endpoint via API
- Fetch post by author slug
- Cant POST with REST API on WordPress
- WordPress json – How to use the content rendered from json
- Subscriber role cann’t add comment meta using REST API
- Restrict Image Sizes and Dimensions when Uploading via the WP Mobile App
- Can I use the Backbone REST API client outside WordPress?
- WordPress REST API function not calling from external site
- Issue with API after 6.2 update
- Verify user login and password over api