updated api links to follow config.php

This commit is contained in:
Erwin Galang 2024-02-15 22:24:47 +08:00
parent 02387180ee
commit 2bb8b8062b
1 changed files with 5 additions and 5 deletions

View File

@ -200,7 +200,7 @@ $array = json_decode($result, true);
<script>
function deleteImage(productId, indexToDelete) {
fetch('https://api.obanana.shop/api/v1/products/' + productId)
fetch('https://<?php echo $_SESSION["data_endpoint"]; ?>/api/v1/products/' + productId)
.then(response => response.json())
.then(product => {
let imagesArray = product.images.split(',');
@ -212,7 +212,7 @@ $array = json_decode($result, true);
images: updatedImages,
};
const token = '<?php echo $_SESSION["token"] ?>';
return fetch('https://api.obanana.shop/api/v1/products/' + productId, {
return fetch('https://<?php echo $_SESSION["data_endpoint"]; ?>/api/v1/products/' + productId, {
method: 'PATCH',
headers: {
'Content-Type': 'application/json',
@ -434,7 +434,7 @@ $array = json_decode($result, true);
var promises = [];
var existingImages = [];
fetch('https://api.obanana.shop/api/v1/products/' + productId)
fetch('https://<?php echo $_SESSION["data_endpoint"]; ?>/api/v1/products/' + productId)
.then(response => response.json())
.then(product => {
existingImages = product.images || [];
@ -503,7 +503,7 @@ $array = json_decode($result, true);
const payload = {
product_image: `https://<?php echo $_SESSION["data_endpoint"]; ?>/images/storage/product_uploads/${filename}`,
};
fetch('https://api.obanana.shop/api/v1/upload_image', {
fetch('https://<?php echo $_SESSION["data_endpoint"]; ?>/api/v1/upload_image', {
method: 'POST',
body: formData
})
@ -537,7 +537,7 @@ $array = json_decode($result, true);
Promise.all(promises)
.then(filenames => {
const updatedImages = existingImages.concat(filenames.map(filename => `https://api.obanana.shop/images/storage/product_uploads/${filename}`));
const updatedImages = existingImages.concat(filenames.map(filename => `https://<?php echo $_SESSION["data_endpoint"]; ?>/images/storage/product_uploads/${filename}`));
if (!Array.isArray(updatedImages)) {
console.error('Updated images is not an array:', updatedImages);