Skip to content

Testing Component Web Services

Before proceeding with the testing, ensure that:

  • Login: Ensure you're logged into a Formbird domain, such as comp-dev-ng.formbird.com. This URL is just an example; the procedure applies to any Formbird domain.
  • Correct Tab: You must run the test in a browser tab that has the Formbird domain open.

Steps

  1. Open Browser's Console: Access the console via Ctrl+Shift+I (Windows/Linux) or Cmd+Opt+I (Mac), then navigate to the "Console" tab.
  2. Execute the Code: Copy and paste the following JavaScript snippet into the console and press Enter:
const res = await fetch("https://comp-dev-ng.formbird.com/api/execute", {
    method: "POST",
    headers: {'Content-Type': 'application/json'},
    body: JSON.stringify({
        componentDocumentName: "ws-test-service",
        functionName: "getGreeting"
    })
});

if (res.status === 200) {
    const data = await res.json();
    console.log(data);
} else {
    const errorText = await res.text(); // Get the error message as text
    console.log(`Error ${res.status}: ${errorText}`);
}

After executing the code snippet in your browser's console, you should see a JSON object {"greeting": "hello world"} outputted in the console. This indicates that the web service has been successfully called and executed.