R
Reactiflux

help-js

✅ – _mercury – 21-58 Dec 25

M_mercury12/25/2022
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
});
}
SScriptyChris12/25/2022
Where do you see 2 requests?
M_mercury12/25/2022
network tab and they are from this func
SScriptyChris12/25/2022
What is HTTP method in first request - OPTIONS maybe?
M_mercury12/25/2022
Both are POST
SScriptyChris12/25/2022
Can you put console.log in saveProduct function's first line to make sure the function gets called only once?
M_mercury12/25/2022
M_mercury12/25/2022
Called twice
SScriptyChris12/25/2022
What calls that function?
M_mercury12/25/2022
mmm i will check Yes that was the issue Smashed
UUUnknown User12/26/2022
3 Messages Not Public
Sign In & Join Server To View

Looking for more? Join the community!