Compare commits
2 Commits
2a6882fd75
...
c8529f58cf
Author | SHA1 | Date |
---|---|---|
erwin | c8529f58cf | |
Erwin Galang | 2bb8b8062b |
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue