#matt-r_code

1 messages ¡ Page 1 of 1 (latest)

queen daggerBOT
#

👋 Welcome to your new thread!

⏲️ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.

⏱️ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.

🔗 This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1288446630638649385

📝 Have more to share? Add more details, code, screenshots, videos, etc. below.

shell cargo
#

As the form would not allow the full code here is what I've got:

expressCheckoutElement.on('shippingaddresschange', async (event) => {

    const options = {
        method: 'POST',
        headers: {'Content-Type': 'application/x-www-form-urlencoded'},
        body: new URLSearchParams({postcode: event.address.postal_code})
    };

    fetch('/api/checkout/address-validation', options)
        .then(response => response.json())
        .then(response => {
            if (response.success === true) {
                event.resolve();
            } else {
                event.reject({
                    shippingRate: [],
                });
            }
        })
        .catch(err => console.error(err));
});
elder knoll
#

Hi, let me help you with this.

shell cargo
#

Thank you, this is specifically relating to the express link element

elder knoll
shell cargo
#

Ah no you can't that was a hang over from testing.

elder knoll
#

So what's your challenge exactly?

shell cargo
#

That updated code looked to work, has it recently changed?
Apologies for the late reply.

Previously when I attempted to set via the async method it would not respond

elder knoll
#

I don't understand what you mean, sorry.

shell cargo
#

The code provided in the link you had sent worked.
Changed: expressCheckoutElement.on('shippingaddresschange', async (event) => { to expressCheckoutElement.on('shippingaddresschange', function (event) {

#

Thanks for showing me the right link in the documentation