<?php

// GET

$args = array(
	'sslverify' => false,
);
$response = wp_remote_get($api_url, $args);


// POST

$args = array(
	'timeout' => 30,
	'httpversion' => '1.1',
	'sslverify' => false,
	'body' => array(
		'username' => 'avengers',
		'password' => 'infinitywars',
	),
	'headers' => array(
		//...
	),
);
$response = wp_remote_post($api_url, $args);


// Handle error and response

if (!is_wp_error($response)) { // check if the passed response is an WP_Error object
	// var_dump($response);
	// echo $response['body'];

	// retrieve response body and convert to a php array
	$body = json_decode(wp_remote_retrieve_body($response), true);
	// retrieve response body and convert to a json
	$viewData = json_encode(wp_remote_retrieve_body($response));
	// TODO: almacenar en localstorage o window para poder acceder desde VUE
} else {
	// retrieve error code (200, 400, etc)
	$errorCode = wp_remote_retrieve_response_code($response)
}

?>