Integrations
JavaScript
Send contacts to nodenly. One with fetch from any JavaScript website (React, Next.js, Vue, Webflow, Wix), with errors handled and no duplicates.
Use this when you already have a form and want to keep its design and behaviour.
async function sendLead(form) {
const data = Object.fromEntries(new FormData(form));
const response = await fetch("https://www.nodenly.com/api/v1/leads", {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: "Bearer pk_live_YOUR_KEY",
// Same value if this submission is sent again (double click, retry): it is stored once.
"Idempotency-Key": form.dataset.submissionId ??= crypto.randomUUID(),
},
body: JSON.stringify({
name: data.name,
email: data.email,
message: data.message,
page_url: location.href,
fields: { service: data.service },
}),
});
if (response.ok) return { ok: true };
const { error } = await response.json();
return { ok: false, code: error.code, field: error.field, message: error.message };
}Answers
| Status | Meaning |
|---|---|
201 | Stored. The body is { "ok": true, "id": "…" } |
200 | Same Idempotency-Key as before: nothing new stored, the first answer is returned (header Idempotent-Replayed: true) |
4xx | Refused: error.code says why, error.field points to the field (see the API reference) |
429 | Too many requests: wait the seconds in Retry-After |
Show your visitor a friendly message for invalid_field (for example "Please check your email") and a generic one for anything else.
Good to know
- Calls from the browser are allowed from your authorized domains (CORS is handled for you).
- Use the public key in browsers. In server code (Next.js route handlers, Node, PHP) use the secret key and no
Originis needed. - Any field you put in
fields(up to 30) shows in the client's page.