> ## Documentation Index
> Fetch the complete documentation index at: https://docs.confidolegal.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Submitting the Fields

Call this method when you are ready to submit the data in the fields. This method returns a Promise that you can `await` or you can pass in a `callback`. The `callback` will be invoked when the field data has been submitted successfully or there was an error.

Once the data is submitted successfully, you are ready to finish the payment on your server.

```javascript theme={"system"}
window.confidoHostedFields.submitFields(callback: SubmitFieldsCallback);
```

### Example with Promise

```javascript theme={"system"}
const handleSubmit = async () => {
  try {
    await window.confidoHostedFields.submitFields();
    // the fields were submitted successfully
  } catch (error) {
    // do something to show the error
  }
};
```

### Example with callback

```javascript theme={"system"}
const handleSubmit = () => {
  window.confidoHostedFields.submitFields((error) => {
    if (error) {
      // do something to show the error
      return;
    }

    // else the fields were submitted successfully
  });
};
```
