The API response includes priceCents in every in-zone response. Use it to show the correct fee immediately.
async function getDeliveryPrice(postcode) {
const res = await fetch('https://api.deliveryzone.fi/v1/check', {
method: 'POST',
headers: { 'X-Api-Key': process.env.DZ_KEY, 'Content-Type': 'application/json' },
body: JSON.stringify({ destinationPostcode: postcode }),
});
const data = await res.json();
if (!data.canDeliver) return null;
return data.priceCents; // e.g. 590 (€5.90)
}
// Display to customer
const price = await getDeliveryPrice('00100');
if (price !== null) {
showDeliveryFee(price / 100); // convert cents to euros
}