Uncaught ReferenceError: wp_remote_get() is not defined
-
I am creating a plugin MICplugins.php used with just one page. Per Block Editor Handbook/Loading JavaScript instruction, this much works fine, including this snippet:
function micDitchHealth_enqueue() { wp_enqueue_script( 'micDitchHealth-script', // script name // micDitchHealth.js in same folder as this .php file. plugins_url( 'MICplugins.js', __FILE__ ), array( 'wp-blocks' ) ); } add_action( 'enqueue_block_editor_assets', 'micDitchHealth_enqueue' );Here’s a snippet from the MICplugins.js file the .php file points to. Note the wp_remote_get(…) example URL call:
console.log( "micDitchHealth-script loaded" ); $response = wp_remote_get( 'https://www.google.com' );At the time a new Post (or page) is created, the MICplugins.js file loads along with the Post, but Inspect / Console (using Chrome browser) reports “Uncaught ReferenceError: wp_remote_get is not defined”. I see that this function is defined in wp-includes/http.php, but obviously I’m missing something to link the definition to a call of it. I presumably will have the same problem with any other js function from the wp core library or related API libraries.
What am I missing?
Any help for this newbie is greatly appreciated. Thank you in advance!
The topic ‘Uncaught ReferenceError: wp_remote_get() is not defined’ is closed to new replies.