✅ – _mercury – 21-58 Dec 25

what could by the reason that this func sends 2 reqs ?
async saveProduct(cartoon) {
this.order.err = null;
this.order.success = null;
const response = await fetch(
'/orders/{{ $order->id }}/add-product-to/' + cartoon.number, {
method: 'POST',
headers: {
'X-CSRF-Token': document.querySelector('input[name=_token]')
.value
},
body: JSON.stringify(this.order)
});
if (response.ok) {
this.order.success = true;
this.order.err = null;
const product = await response.json();
const activeCartoon = this.order.cartoons.find(c => c.number == cartoon
.number);
// console.log(product);
activeCartoon.products.push({
number: product.packed_by_mfg_serial ? product.mfg_serial :
product.serial,
name: product.product
});
}
async saveProduct(cartoon) {
this.order.err = null;
this.order.success = null;
const response = await fetch(
'/orders/{{ $order->id }}/add-product-to/' + cartoon.number, {
method: 'POST',
headers: {
'X-CSRF-Token': document.querySelector('input[name=_token]')
.value
},
body: JSON.stringify(this.order)
});
if (response.ok) {
this.order.success = true;
this.order.err = null;
const product = await response.json();
const activeCartoon = this.order.cartoons.find(c => c.number == cartoon
.number);
// console.log(product);
activeCartoon.products.push({
number: product.packed_by_mfg_serial ? product.mfg_serial :
product.serial,
name: product.product
});
}
S
ScriptyChris478d ago
Where do you see 2 requests?
M
_mercury478d ago
network tab and they are from this func
S
ScriptyChris478d ago
What is HTTP method in first request - OPTIONS maybe?
M
_mercury478d ago
Both are POST
S
ScriptyChris478d ago
Can you put console.log in saveProduct function's first line to make sure the function gets called only once?
M
_mercury478d ago
M
_mercury478d ago
Called twice
S
ScriptyChris478d ago
What calls that function?
M
_mercury478d ago
mmm i will check Yes that was the issue Smashed
UU
Unknown User478d ago