#Astro - page refresh sends button post request again.....

3 messages · Page 1 of 1 (latest)

tired vine
#

Hi there - new to Astro - love it so far but noticed something weird. I've got a button in a form with a method of POST. I click on the button then I refresh and it sends the request again so I've got double requests. Haven't tested in production. Anyone know how to solve this behaviour?

--- 
import Stripe from 'stripe';
const stripe = new Stripe('sk_test_sk');


if (Astro.request.method === 'POST') {

const customer = await stripe.customers.create({
  email: 'testcust@tester.local'
});

console.log(customer.id,'NEW CUSTOMER ID');

}

--- 

<form method="POST">

    <button >Create New Customer</button>

</form>
silk graniteBOT
#
No-one around right now?

It looks like no-one has responded to your question yet. People might not be available right now or don’t know how to answer your question. Want an answer while you wait? Try asking our experimental bot in #1095492539085230272.

cloud thicket
#

Did you solve the problem, @tired vine ? I noticed the same thing.