> For the complete documentation index, see [llms.txt](https://hichemtech.gitbook.io/reqease-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hichemtech.gitbook.io/reqease-docs/requester/request.md).

# Request

In ReqEase's Requester module, the `request` option allows you to configure the HTTP request (AJAX) to suit your specific needs. Underneath, this "request" option utilizes jQuery AJAX for making HTTP requests. Here, we'll delve into the available configuration options for customizing your requests.

## **Basic Request Options**

### **Automatic Inference of URL, Method, and DataType**

When working with ReqEase's Requester module, you can simplify your configuration by leveraging automatic inference for the `url`, `method`, and `dataType` parameters. If you choose not to specify these values in your configuration options, ReqEase intelligently extracts them from the associated HTML form element.

Consider this scenario: You have an HTML form with defined attributes such as `action`, `method`, and `enctype`. ReqEase can automatically detect these attributes to determine the following:

* `url`: The URL where the HTTP request will be sent, extracted from the form's `action` attribute.
* `method`: The HTTP method for the request, obtained from the form's `method` attribute.
* `dataType`: The expected data type of the response, derived from the form's `enctype` attribute, which often matches the data format of the response.

By allowing ReqEase to make these inferences, you streamline your configuration process, especially when working with standard HTML forms that adhere to common conventions. Here's how you can put this feature into action:

```javascript
const form = document.getElementById('myForm'); // Replace 'myForm' with your form's ID

const requester = new Requester({
    form: form, // Associate Requester with a specific form
    // ...other configuration options
});
```

This feature not only simplifies your code but also ensures that ReqEase efficiently utilizes the information readily available in your HTML forms to construct HTTP requests.

### **Manual Request Configuration:**

Of course, you have the flexibility to manually specify the `url`, `method`, and `dataType` in your configuration options if your setup requires custom values. Additionally, you can provide a custom `data` object to include specific data in your request. Here's a closer look at the available configuration options:

* `url` (string): The URL to which the HTTP request will be sent.
* `method` (HttpMethod): The HTTP method to use for the request (e.g., GET, POST, PUT).
* `data` (any): The data to include in the request payload.
* `dataType` (DataType): The expected data type of the response (e.g., 'json', 'xml', 'html').
* `headers` ({ \[key: string]: string }): Custom HTTP headers to include in the request.
* `beforeSend` ((jqXHR: jqXHR, settings: any) => false | void): A function that can be used to modify the request before it is sent. If it returns `false`, the request will be canceled.
* `ajaxExtraOptions` ({ \[key: string]: any }): Additional options that can be passed directly to the jQuery AJAX request.

### **Data Source Configuration:**

Within the Requester module, there's an option called `data` which can be configured in a few different ways. It determines what data is sent in your AJAX request. This is especially useful for cases where your data originates from your form's input fields.

* If you set `data` to `'auto'`, ReqEase will automatically build the request data by collecting values from the form's input fields. This automatic data collection simplifies your setup by using form data as is.
* Alternatively, you can manually specify an array of HTML elements in the `data` option. ReqEase will then build the request data exclusively from these selected elements.
* If you set `data` to `null` or `undefined`, the request data will remain empty, allowing you to construct it manually if needed.

By configuring the request options and data handling, you can precisely control how your HTTP requests are formed and sent within the Requester module, which relies on jQuery AJAX under the hood. This flexibility ensures your application can interact with APIs and servers as needed.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://hichemtech.gitbook.io/reqease-docs/requester/request.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
