Im making API request from facebook graph api. i would like to hide the id and access token from client side. so i stored the access token on php then i got the data with js. but then i realized that it still shows on the console.log . how can i make it secure ? how to hide the api key? the data still show on the console so im not sure how i can hide thed data. i also have tried .env method but i know i can access from client side only on server side.
let faceIDnum = sns_show_options.facebookID;
let faceID = faceIDnum.toString();
console.log(faceID);
const businessIDface = faceID ;
this is how i did with js.
require_once __DIR__ . '/vendor/autoload.php';
$dotenv = Dotenv\Dotenv::createImmutable(__DIR__);
$dotenv->load();
$snspostcount = get_option('post_count_number');
$sns_facebook_id_info = get_option('facebook_page_id' );
$sns_post_count = putenv("SNS_POST_TOTAL=$snspostcount");
$sns_post_count_val = getenv('SNS_POST_TOTAL');
$sns_facebook = putenv("SNS_FACEBOOK_ID=$sns_facebook_id_info");
$sns_facebook_id = getenv('SNS_FACEBOOK_ID');
// $nametag = $_ENV["SKDAI"];
var_dump($sns_post_count_val);
function wp_enqueue_javascript_scripts() {
wp_register_script( 'javascript-js', get_template_directory_uri() . './js/index.js', array(), '1.0.0', true );
wp_enqueue_script( 'javascript-js' );
wp_localize_script( 'javascript-js', 'sns_show_options',
[
'facebookID'=> getenv('SNS_FACEBOOK_ID')
]
);
}