Skip to content
Snippets Groups Projects
Commit 179bcf06 authored by althaafka's avatar althaafka
Browse files

refactor(premium film): get rest url from api

parent e7755b1e
1 merge request!1merge develop
...@@ -9,6 +9,7 @@ define('PORT', $_ENV['POSTGRES_PORT']); ...@@ -9,6 +9,7 @@ define('PORT', $_ENV['POSTGRES_PORT']);
define('SOAP_API', $_ENV['PHP_SOAP_URL']); define('SOAP_API', $_ENV['PHP_SOAP_URL']);
define('SOAP_KEY', $_ENV['SOAP_KEY']); define('SOAP_KEY', $_ENV['SOAP_KEY']);
define('REST_URL', $_ENV['PHP_REST_URL']);
define('MAX_SIZE_PROFILE', 800 * 1024); define('MAX_SIZE_PROFILE', 800 * 1024);
define('MAX_SIZE_POSTER', 1 * 1024 * 1024 ); define('MAX_SIZE_POSTER', 1 * 1024 * 1024 );
define('MAX_SIZE_VIDEO', 5 * 1024 * 1024 ); define('MAX_SIZE_VIDEO', 5 * 1024 * 1024 );
......
...@@ -17,6 +17,9 @@ ...@@ -17,6 +17,9 @@
</head> </head>
<body> <body>
<script type="text/javascript" defer>
const PHP_REST_URL = "<?php echo REST_URL;?>";
</script>
<?php include(DIRECTORY. "/../view/components/NavbarUser.php"); ?> <?php include(DIRECTORY. "/../view/components/NavbarUser.php"); ?>
<section> <section>
<header> <header>
......
...@@ -20,6 +20,9 @@ ...@@ -20,6 +20,9 @@
<script type="text/javascript" src="/javascript/user/premiumFilm.js" defer></script> <script type="text/javascript" src="/javascript/user/premiumFilm.js" defer></script>
</head> </head>
<body> <body>
<script type="text/javascript" defer>
const PHP_REST_URL = "<?php echo REST_URL;?>";
</script>
<?php include (DIRECTORY. "/../view/components/NavbarUser.php"); ?> <?php include (DIRECTORY. "/../view/components/NavbarUser.php"); ?>
<?php include(DIRECTORY . "/../view/components/loading.php"); ?> <?php include(DIRECTORY . "/../view/components/loading.php"); ?>
<section> <section>
......
const PHP_REST_URL = 'http://localhost:8000';
const pathname = window.location.pathname.split('/'); const pathname = window.location.pathname.split('/');
const filmID = pathname[pathname.length-1]; const filmID = pathname[pathname.length-1];
......
const card_container = document.getElementById("result-container"); const card_container = document.getElementById("result-container");
const PHP_REST_URL = `http://localhost:8000`;
const LIMIT = 6; const LIMIT = 6;
let pagination_count = 0; let pagination_count = 0;
function addButtonPagination(val, symbol, is_active){ function addButtonPagination(val, symbol, is_active){
// console.log(val, symbol, is_active);
pagination_container.innerHTML += ` pagination_container.innerHTML += `
<div class="button-pagination ${is_active? "button-red":"button-white"}" value=${val} symbol="${symbol}" onClick=handlePagination(this.getAttribute('value'))> <div class="button-pagination ${is_active? "button-red":"button-white"}" value=${val} symbol="${symbol}" onClick=handlePagination(this.getAttribute('value'))>
${symbol} ${symbol}
...@@ -152,11 +149,13 @@ async function handlePagination(val){ ...@@ -152,11 +149,13 @@ async function handlePagination(val){
} }
console.log(PHP_REST_URL);
const xhr = new XMLHttpRequest(); const xhr = new XMLHttpRequest();
xhr.open('GET', `${PHP_REST_URL}/films/premium-film/0`); xhr.open('GET', `${PHP_REST_URL}/films/premium-film/0`);
xhr.send(); xhr.send();
xhr.onreadystatechange = async () => { xhr.onreadystatechange = async () => {
if (xhr.readyState === XMLHttpRequest.DONE){ if (xhr.readyState === XMLHttpRequest.DONE){
console.log(xhr.responseText);
var response = JSON.parse(xhr.responseText); var response = JSON.parse(xhr.responseText);
if (xhr.status === 200){ if (xhr.status === 200){
console.log(response); console.log(response);
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment