FormsGuidesJavaScript

JavaScript Integration

JavaScript is a high-level, versatile programming language primarily used to create dynamic and interactive features on websites. It is a core technology of the web, alongside HTML and CSS, and enables both client-side and server-side development.

To get started, you’ll need the following:

Use this on your JavaScript Project to send form data to your endpoint.

Send data using the Fetch API, Axios or Any HTTP client and ensure the mode on the query string is set to mode=rest for retrieving the response in JSON format.

Copy and paste this into your JavaScript file.

Feel free to use the code below to send a test submission.

try {
  const res = await fetch("https://forms.basestack.co/api/v1/s/[KEY]?mode=rest", {
    method: "POST",
    headers: {
      Accept: "application/json",
      "Content-Type": "application/json",
    },
    body: JSON.stringify({ name: "John Doe", message: "Hello World" }),
  });
 
  const data = await res.json();
 
  if (data.code === 200) {
    console.log("Form submitted successfully");
  }
} catch (error) {
  console.log("Error submitting form", error);
}