WP Rest API and json_decode()
wp_remote_get return array of results containing keys body, headers, response etc depending on arguments. And json_decode only accept JSON string. So correct your code in this way //return if not an error if ( ! is_wp_error( $response ) ) { //decode and return return json_decode( wp_remote_retrieve_body( $response ) ); } Ref: Return Values of wp_remote_get … Read more