DNZ Digita

WhatsApp OTP Example

Request WhatsApp OTP from React

A safe React example that calls your own backend instead of calling DNZ directly.

Setup

Code

async function requestOtp(phone) {
  const res = await fetch("/api/request-otp", {
    method: "POST",
    headers: { "Content-Type": "application/json" },
    body: JSON.stringify({ phone }),
  });

  if (!res.ok) throw new Error("Unable to request OTP");
  return res.json();
}

Production notes

Related links

Support